cache

package
v1.63.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Copies

type Copies interface {
	// Get returns the copy of ref, if there is one.
	Get(ref *proto.Ref) (*proto.Object, bool)
	// Put keeps obj as the copy of ref.
	Put(ref *proto.Ref, obj *proto.Object) error
	// Drop forgets the copy of ref.
	Drop(ref *proto.Ref)
}

Copies holds a Store's copies of objects by ref. *blobcache.Cache is one on disk, Memory one for a single process, and InStore adapts an object store.

func InStore

func InStore(store backup.ObjectStore) Copies

InStore keeps Copies in an object store such as a local badger store.

type Memory

type Memory struct {
	// contains filtered or unexported fields
}

Memory is Copies held in memory for as long as it is referenced.

func NewMemory

func NewMemory() *Memory

NewMemory returns empty Copies in memory.

func (*Memory) Drop

func (m *Memory) Drop(ref *proto.Ref)

Drop implements Copies.

func (*Memory) Get

func (m *Memory) Get(ref *proto.Ref) (*proto.Object, bool)

Get implements Copies.

func (*Memory) Put

func (m *Memory) Put(ref *proto.Ref, obj *proto.Object) error

Put implements Copies.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store serves metadata objects from its copies before wrapped, filling them on reads and writes; failures to keep a copy are ignored. Objects are immutable by ref, so a copy is never stale; what is newest is still the wrapped store's to say.

func New

func New(copies Copies, wrapped backup.ObjectStore) *Store

New layers copies over wrapped for its commits, trees and files.

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, ref *proto.Ref) error

Delete implements backup.ObjectStore.

func (*Store) Get

func (s *Store) Get(ctx context.Context, ref *proto.Ref) (*proto.Object, error)

Get implements backup.ObjectStore.

func (*Store) GetTree

func (s *Store) GetTree(ctx context.Context, ref *proto.Ref, maxDepth uint32) ([]*proto.Object, error)

GetTree serves the tree at ref and its splits from the copies when it holds them all, and otherwise forwards to the wrapped store's prefetch, if it has one, keeping what it fetched. Trees below are left to later calls.

func (*Store) Has

func (s *Store) Has(ctx context.Context, ref *proto.Ref) (bool, error)

Has implements backup.ObjectStore.

func (*Store) Keep

func (s *Store) Keep(ctx context.Context, obj *proto.Object)

Keep implements backup.Keeper.

func (*Store) Put

func (s *Store) Put(ctx context.Context, object *proto.Object) error

Put implements backup.ObjectStore.

func (*Store) Unwrap

func (s *Store) Unwrap() backup.ObjectStore

Unwrap implements wrapped.Wrapper.

func (*Store) Walk

func (s *Store) Walk(ctx context.Context, b bool, objectType proto.ObjectType, receiver backup.ObjectReceiver) error

Walk implements backup.ObjectStore.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL