Bundle embedded databases with fixed api https://pkg.go.dev/github.com/ucwong/golang-kv
Interfaces
type Bucket interface {
Get(k []byte) []byte
Set(k, v []byte) error
Del(k []byte) error
Prefix(k []byte) [][]byte
Suffix(k []byte) [][]byte
Scan() [][]byte
Range(start, limit []byte) [][]byte
SetTTL(k, v []byte, expire time.Duration) error
Close() error
// BatchSet write & flush
BatchSet(kvs map[string][]byte) error
Name() string
}
used by
import "github.com/ucwong/golang-kv"
...
badger := kv.Badger("")
defer badger.Close()
badger.Set([]byte("x"), []byte("y")))
v := badger.Get([]byte("x"))
vs := badger.Prefix([]byte("x"))
...
bolt := kv.Bolt("")
defer bolt.Close()
bolt.setTTL([]byte("k"), []byte("v"), time.Second)
...
ldb := kv.LevelDB("")
defer ldb.Close()
...
peb := kv.Pebble("")
defer peb.Close()
...
nut := kv.NutsDB("")
defer nut.Close()
...
make test