/golang-kv

Bundle embedded DB (badger & boltdb & leveldb & pebble & nutsdb) wrapper with fixed & simple api of pure Golang

Primary LanguageGoGNU General Public License v3.0GPL-3.0

Golang-kv

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()
...

Test

make test

Repobeats

Alt

How to choose database engine

image

image