gkv is an embeddable, persistent, simple key/value(KV) database adapter for Go.
This package depends on third-party databases.
- Out of the box, easy to use.
- Basic, common, pure Go.
- Support multiple databases.
- bolt - an embedded key/value database for Go.[GitHub]
- badger - fast key-value DB in Go.[GitHub]
- leveldb - key/value database in Go.[GitHub]
- buntdb - an embeddable, in-memory key/value database for Go with custom indexing and geospatial support.[GitHub]
- sqlite3 - sqlite3 driver for go using database/sql.[GitHub]
go get -u github.com/WindomZ/gkv/...
import (
"github.com/WindomZ/gkv"
_ "github.com/WindomZ/gkv/bolt"
)
...
// init db
db := Open("../data/bolt.db")
db.Register([]byte("tablename"))
...
// put the value for a key
db.Put([]byte("key1"), []byte("value1"))
db.Put([]byte("key2"), []byte("value2"))
...
// get the value for a key
demo.Get([]byte("key1"))
demo.Get([]byte("key2"))
If you want to switch between different databases, just change import _ "github.com/WindomZ/gkv/bolt"
.
For example:
- bolt -
import _ "github.com/WindomZ/gkv/bolt"
- badger -
import _ "github.com/WindomZ/gkv/badger"
- leveldb -
import _ "github.com/WindomZ/gkv/leveldb"
- buntdb -
import _ "github.com/WindomZ/gkv/buntdb"
- sqlite3 -
import _ "github.com/WindomZ/gkv/sqlite3"
Easy to switch, choose the most suitable database.
Welcome to pull requests, report bugs, suggest ideas and discuss on issues page.
If you like it then you can put a ⭐ on it.