badger

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrKeyAlreadyExist represent the error when the key is already present in the key
	// value store.
	ErrKeyAlreadyExist = errors.New("key already exist in the key value store")
)

Functions

This section is empty.

Types

type Backend

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

Backend is the backend for badger key value store for xene.

func NewBadgerBackend

func NewBadgerBackend(dir string) (*Backend, error)

NewBadgerBackend configures and returns badger backend.

func (*Backend) Close

func (b *Backend) Close() error

Close closes the database client and does not allow to do any more transactions.

func (*Backend) Configured

func (b *Backend) Configured() bool

Configured returns if the backend client has been configured or not.

func (*Backend) CreateIfExists

func (b *Backend) CreateIfExists(ctx context.Context, condKey, key string, value []byte) error

CreateIfExists creates a key with the value only if key condKey exists

func (*Backend) CreateOnly

func (b *Backend) CreateOnly(ctx context.Context, key string, value []byte) (bool, error)

CreateOnly atomically creates a key or fails if it already exists

func (*Backend) Decode

func (b *Backend) Decode(in string) ([]byte, error)

Decode decodes a key previously encoded back into the original binary slice

func (*Backend) Delete

func (b *Backend) Delete(ctx context.Context, key string) error

Delete deletes a key

func (*Backend) DeletePrefix

func (b *Backend) DeletePrefix(ctx context.Context, path string) error

DeletePrefix deletes the first key which matches the prefix and its value.

func (*Backend) Encode

func (b *Backend) Encode(in []byte) string

Encode encodes a binary slice into a character set that the backend supports

func (*Backend) Exists

func (b *Backend) Exists(ctx context.Context, key string) (bool, error)

Exists checks if the key provided exists in the datastore or not.

func (*Backend) Get

func (b *Backend) Get(ctx context.Context, key string) (*types.Value, error)

Get returns the value of the key.

func (*Backend) GetName

func (b *Backend) GetName() string

GetName returns the name of the badger backend.

func (*Backend) GetPrefix

func (b *Backend) GetPrefix(ctx context.Context, path string) (string, *types.Value, error)

GetPrefix returns the first key which matches the prefix and its value

func (*Backend) KeyDoesNotExistError

func (b *Backend) KeyDoesNotExistError(err error) bool

KeyDoesNotExistError checks if the provided error is due to non existance of the key or not.

func (*Backend) ListPrefix

func (b *Backend) ListPrefix(ctx context.Context, path string) (types.KeyValuePairs, error)

ListPrefix returns a list of keys matching the prefix This is best effort.

func (*Backend) ListPrefixKeys

func (b *Backend) ListPrefixKeys(ctx context.Context, path string) ([]string, error)

ListPrefixKeys returns a list of keys matching the prefix This is best effort.

func (*Backend) PrefixScanWithFunction

func (b *Backend) PrefixScanWithFunction(ctx context.Context,
	key string, f types.KVPairStructFunc)

PrefixScanWithFunction scans the provided key prefix keys in the store and run the provided function for each one of them.

func (*Backend) Set

func (b *Backend) Set(ctx context.Context, key string, value []byte) error

Set sets value of key

func (*Backend) Status

func (b *Backend) Status() (string, error)

Status returns the status of the initialized backend, it returns an error if anything is wrong with the backend module.

Jump to

Keyboard shortcuts

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