Help us shape the future of Go! Take the 2026 Go Developer Survey

cache

package
v1.96.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 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 Recent added in v1.96.0

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

Recent is Copies in memory that hold what was kept or read since the generation before the current one: Rotate starts a generation and drops every copy the one before it neither kept nor read. Rotated once per commit, it holds what the last commit wrote and what it read of the one before, and nothing older.

func NewRecent added in v1.96.0

func NewRecent() *Recent

NewRecent returns empty Recent copies.

func (*Recent) Drop added in v1.96.0

func (r *Recent) Drop(ref *proto.Ref)

Drop implements Copies.

func (*Recent) Get added in v1.96.0

func (r *Recent) Get(ref *proto.Ref) (*proto.Object, bool)

Get implements Copies; a copy of the previous generation joins the current one.

func (*Recent) Put added in v1.96.0

func (r *Recent) Put(ref *proto.Ref, obj *proto.Object) error

Put implements Copies.

func (*Recent) Rotate added in v1.96.0

func (r *Recent) Rotate()

Rotate starts a generation.

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) Kept added in v1.96.0

func (s *Store) Kept(ref *proto.Ref) bool

Kept implements backup.Keeper: a copy of ref is kept here, or by the wrapped store where it is a Keeper.

func (*Store) Missing added in v1.96.0

func (s *Store) Missing(ctx context.Context, refs []*proto.Ref) ([]*proto.Ref, error)

Missing implements backup.Batcher through the wrapped store.

func (*Store) Put

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

Put implements backup.ObjectStore.

func (*Store) PutCommits added in v1.92.0

func (s *Store) PutCommits(ctx context.Context, commits []*proto.Object) error

PutCommits implements backup.CommitBatcher through the wrapped store.

func (*Store) PutObjects added in v1.96.0

func (s *Store) PutObjects(ctx context.Context, objects []*proto.Object) error

PutObjects implements backup.Batcher through the wrapped store.

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