badgerstore

package module
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2025 License: Apache-2.0 Imports: 12 Imported by: 3

README

badgerstore

GoDoc CI

Package badgerstore implements the blob.Store interface using BadgerDB.

Documentation

Overview

Package badgerstore implements the blob.Store interface using BadgerDB.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Opener

func Opener(_ context.Context, addr string) (blob.StoreCloser, error)

Opener constructs a filestore from an address comprising a URL, for use with the store package. The host and path of the URL give the path of the database directory.

Optional query parameters include:

base_size=n      : base table size in MiB (default 2)
compact_on_close : do a L0 compaction on close (default true)
index_cache=m    : index cache size in MiB (default 50)
read_only        : open the database in read-only mode (default false)
auto_sync        : automatically sync writes when GCing (default false)

Types

type KV added in v0.6.0

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

KV implements the blob.KV interface using a Badger key-value store.

func NewKV added in v0.7.0

func NewKV(opts Options) (KV, error)

NewKV creates a KV by opening the Badger database specified by opts.

func (KV) Close added in v0.6.0

func (s KV) Close(_ context.Context) error

Close implements part of the blob.KV interface. It closes the underlying database instance and reports its result.

func (KV) Delete added in v0.6.0

func (s KV) Delete(_ context.Context, key string) error

Delete implements part of blob.KV.

func (KV) Get added in v0.6.0

func (s KV) Get(_ context.Context, key string) (data []byte, err error)

Get implements part of blob.KV.

func (KV) Has added in v0.9.0

func (s KV) Has(_ context.Context, keys ...string) (blob.KeySet, error)

Has implements part of blob.KV.

func (KV) Len added in v0.6.0

func (s KV) Len(ctx context.Context) (int64, error)

Len implements part of blob.KV.

func (KV) List added in v0.6.0

func (s KV) List(ctx context.Context, start string) iter.Seq2[string, error]

List implements part of blob.KV.

func (KV) Put added in v0.6.0

func (s KV) Put(_ context.Context, opts blob.PutOptions) error

Put implements part of blob.KV.

type Options added in v0.4.0

type Options struct {
	// Badger are the options to use for creating or opening a BadgerDB.
	// At least the Dir field must be set.
	Badger badger.Options

	// AutoSync, if true, enables automatic periodic sync to disk.
	AutoSync bool

	// KeyPrefix, if non-empty, is automatically prepended to all keys, and
	// scopes the resulting access to only keys having that prefix.
	KeyPrefix string
}

Options are optional settings for a Store or a KV.

type Store

type Store struct {
	*monitor.M[*dbState, KV]
}

Store implements the blob.Store interface using a BadgerDB instance.

func New

func New(opts Options) (Store, error)

New constructs a Store by opening or creating a BadgerDB instance with the specified options.

func (Store) Close

func (s Store) Close(_ context.Context) error

Close satisfies part of the blob.StoreCloser interface.

Jump to

Keyboard shortcuts

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