badger

package
v0.42.0 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Logger is where Badger system logs will go.
	Logger badger.Logger
	// DBPath the path to the database directory.
	DBPath string
	// Truncate whether to truncate the write log to remove corrupt data.
	Truncate bool
	// Allow git snapshots.
	Snapshot bool
	// Badger options to open DB
	BadgerOptions badger.Options
	// In Memory
	InMemory bool
}

Config defines the configurable parameters of the Badger storage implementation.

type Opt

type Opt func(*Config)

func WithLogger

func WithLogger(logger badger.Logger) Opt

func WithPath

func WithPath(path string) Opt

func WithPersist added in v0.38.0

func WithPersist(persist bool) Opt

func WithSnapshot added in v0.34.1

func WithSnapshot(enabled bool) Opt

func WithTruncate

func WithTruncate(trunc bool) Opt

type Store

type Store struct {
	storage.DefaultStore
	// contains filtered or unexported fields
}

Store is an embedded storage implementation using Badger as the underlying persistent key-value store.

func New

func New(opts ...Opt) (*Store, error)

func (*Store) Close

func (s *Store) Close() error

Close closes the underlying Badger database. It is necessary to close a Store before exiting to ensure all writes are persisted to disk.

func (*Store) GetBytes added in v0.40.0

func (s *Store) GetBytes(ctx context.Context, store string, key []byte) (result []byte, err error)

func (*Store) GetBytesAtVersion added in v0.40.0

func (s *Store) GetBytesAtVersion(ctx context.Context, store string, key []byte, version uint64) (result []byte, err error)

func (*Store) JumpToContext added in v0.27.0

func (s *Store) JumpToContext(context string) error

func (*Store) RunValueLogGC

func (s *Store) RunValueLogGC(discardRatio float64) error

func (*Store) SetBytes added in v0.40.0

func (s *Store) SetBytes(ctx context.Context, store string, key []byte, value []byte) (err error)

func (*Store) SetBytesWithVersion added in v0.40.0

func (s *Store) SetBytesWithVersion(ctx context.Context, store string, key []byte, value []byte, version uint64) (err error)

func (*Store) Sync

func (s *Store) Sync() error

Sync syncs database content to disk.

Jump to

Keyboard shortcuts

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