kvstore

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEncryptionKeyNotProvided = errors.New("encryption key not provided")
)

Functions

This section is empty.

Types

type BadgerKVStore

type BadgerKVStore struct {
	DB *badger.DB
}

BadgerKVStore is an implementation of the KVStore interface using BadgerDB.

func NewBadgerKVStore

func NewBadgerKVStore(dbPath string, encryptionKey []byte) (*BadgerKVStore, error)

NewBadgerKVStore creates a new BadgerKVStore instance.

func (*BadgerKVStore) Close

func (b *BadgerKVStore) Close() error

Close closes the BadgerDB.

func (*BadgerKVStore) Delete

func (b *BadgerKVStore) Delete(key string) error

Delete removes a key-value pair from BadgerDB.

func (*BadgerKVStore) Get

func (b *BadgerKVStore) Get(key string) ([]byte, error)

Get retrieves the value associated with a key from BadgerDB.

func (*BadgerKVStore) Keys

func (b *BadgerKVStore) Keys() ([]string, error)

func (*BadgerKVStore) Put

func (b *BadgerKVStore) Put(key string, value []byte) error

Put stores a key-value pair in the BadgerDB.

type KVStore

type KVStore interface {
	// Put stores a key-value pair in the store.
	Put(key string, value []byte) error

	// Get retrieves the value associated with a key. If the key is not found, it returns an empty slice.
	Get(key string) ([]byte, error)

	// Delete removes a key-value pair from the store.
	Delete(key string) error

	// Close closes the key-value store.
	Close() error
}

KVStore defines the interface for a key-value store.

Jump to

Keyboard shortcuts

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