badger

package
v1.65.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: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrLocked = errors.New("another process has the store open")

ErrLocked is returned by New when another process has the Store open.

View Source
var Logger badger.Logger = slogLogger{}

Logger is a badger.Logger that writes through the default slog logger, so badger's lines come out in the program's log format.

Functions

This section is empty.

Types

type Option

type Option func(*Store)

Option configures a Store.

func WithCapacity

func WithCapacity(capacity int64) Option

WithCapacity bounds the bytes of objects a Store keeps: past capacity, the objects least recently read or written are deleted. Only a cache should use it, since an evicted object is gone. 0 leaves the store unbounded. The order of last use survives a reopen, to within ten minutes after a crash.

type Store

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

Store keeps objects in badger, keyed by ref. Each value is the object header, length-prefixed, followed by the stored bytes; the entry's user meta byte carries the object type so Walk can filter without loading.

func New

func New(path string, with ...Option) (*Store, error)

New opens or creates a Store at path. It fails with ErrLocked while another process has it open.

func (*Store) Close

func (s *Store) Close() error

Close releases the database.

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) Has

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

Has implements backup.ObjectStore.

func (*Store) Put

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

Put implements backup.ObjectStore.

func (*Store) Walk

func (s *Store) Walk(ctx context.Context, load bool, filterFor 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