https://github.com/ucwong/golang-kv
Bundle embedded DB (badger & boltdb & leveldb & pebble & nutsdb) wrapper with fixed & simple api of pure Golang
https://github.com/ucwong/golang-kv
badger boltdb embedded-databases-wrapper golang leveldb pebble ttl
Last synced: 6 months ago
JSON representation
Bundle embedded DB (badger & boltdb & leveldb & pebble & nutsdb) wrapper with fixed & simple api of pure Golang
- Host: GitHub
- URL: https://github.com/ucwong/golang-kv
- Owner: ucwong
- License: gpl-3.0
- Created: 2021-03-19T06:45:53.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2025-12-25T15:39:30.000Z (8 months ago)
- Last Synced: 2025-12-27T02:43:38.890Z (8 months ago)
- Topics: badger, boltdb, embedded-databases-wrapper, golang, leveldb, pebble, ttl
- Language: Go
- Homepage:
- Size: 6.85 MB
- Stars: 10
- Watchers: 0
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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

# How to choose database engine

