Skip to content

Commit

Permalink
modify the interface
Browse files Browse the repository at this point in the history
  • Loading branch information
okdas committed Aug 19, 2024
1 parent dfdcbe5 commit be8f5d5
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 25 deletions.
16 changes: 1 addition & 15 deletions kvstore/badger/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,7 @@ var _ kvstore.MapStore = (BadgerKVStore)(nil)
// This is a superset of the MapStore interface that offers more
// features and can be used as a standalone key-value store.
type BadgerKVStore interface {
// --- Store methods ---

// Get returns the value for a given key
Get(key []byte) ([]byte, error)
// Set sets/updates the value for a given key
Set(key, value []byte) error
// Delete removes a key
Delete(key []byte) error
kvstore.MapStore

// --- Lifecycle methods ---

Expand All @@ -41,11 +34,4 @@ type BadgerKVStore interface {
GetAll(prefixKey []byte, descending bool) (keys, values [][]byte, err error)
// Exists returns true if the key exists
Exists(key []byte) (bool, error)
// Len returns the number of key-value pairs in the store
Len() (int, error)

// --- Data management ---

// ClearAll deletes all key-value pairs in the store
ClearAll() error
}
4 changes: 2 additions & 2 deletions kvstore/badger/kvstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ type badgerKVStore struct {

// NewKVStore creates a new BadgerKVStore using badger as the underlying database
// if no path for a persistence database is provided it will create one in-memory
// TODO: consider exposing the low-level options (`badgerv4.Options`) via a config file to make it
// easier to test under different load conditions.
func NewKVStore(path string) (BadgerKVStore, error) {
var db *badgerv4.DB
var err error
Expand Down Expand Up @@ -211,8 +213,6 @@ func prefixEndBytes(prefix []byte) []byte {

// badgerOptions returns the badger options for the store being created
func badgerOptions(path string) badgerv4.Options {
// TODO: If we will use badger for SMT storage, consider exposing the low-level options via a config file to make it
// easier to test under different load conditions.
// Parameters should be adjusted carefully, depending on the type of load. We need to experiment more to find the best
// values, and even then they might need further adjustments as the type of load/environment (e.g. memory dedicated
// to the process) changes.
Expand Down
10 changes: 2 additions & 8 deletions kvstore/pebble/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,11 @@ var _ kvstore.MapStore = (PebbleKVStore)(nil)
// This is a superset of the MapStore interface that offers more
// features and can be used as a standalone key-value store.
type PebbleKVStore interface {
// --- Store methods ---
Get(key []byte) ([]byte, error)
Set(key, value []byte) error
Delete(key []byte) error
kvstore.MapStore

// --- Lifecycle methods ---
Stop() error
// --- Accessors ---
GetAll(prefixKey []byte, descending bool) (keys, values [][]byte, err error)
Exists(key []byte) (bool, error)
// Len returns the number of key-value pairs in the store
Len() (int, error)
// --- Data management ---
ClearAll() error
}
2 changes: 2 additions & 0 deletions kvstore/pebble/kvstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ type pebbleKVStore struct {

// NewKVStore creates a new PebbleKVStore instance.
// If path is empty, it creates an in-memory store.
// TODO: consider exposing the low-level options (`pebble.Options{}`) via a config file to make it
// easier to test under different load conditions.
func NewKVStore(path string) (PebbleKVStore, error) {
store := &pebbleKVStore{}

Expand Down

0 comments on commit be8f5d5

Please sign in to comment.