diff --git a/kvstore/badger/interface.go b/kvstore/badger/interface.go index c6ed609..1b8e710 100644 --- a/kvstore/badger/interface.go +++ b/kvstore/badger/interface.go @@ -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 --- @@ -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 } diff --git a/kvstore/badger/kvstore.go b/kvstore/badger/kvstore.go index 1a9a1c7..367bc68 100644 --- a/kvstore/badger/kvstore.go +++ b/kvstore/badger/kvstore.go @@ -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 @@ -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. diff --git a/kvstore/pebble/interface.go b/kvstore/pebble/interface.go index c0e6c55..29897fa 100644 --- a/kvstore/pebble/interface.go +++ b/kvstore/pebble/interface.go @@ -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 } diff --git a/kvstore/pebble/kvstore.go b/kvstore/pebble/kvstore.go index 020553b..15c86e4 100644 --- a/kvstore/pebble/kvstore.go +++ b/kvstore/pebble/kvstore.go @@ -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{}