Mura Li d77176912b | 5 years ago | |
---|---|---|
.. | ||
config | 5 years ago | |
store | 5 years ago | |
.gitignore | 5 years ago | |
LICENSE | 5 years ago | |
README.md | 5 years ago | |
README_CN.md | 5 years ago | |
batch.go | 5 years ago | |
binlog.go | 5 years ago | |
binlog_util.go | 5 years ago | |
const.go | 5 years ago | |
doc.go | 5 years ago | |
dump.go | 5 years ago | |
info.go | 5 years ago | |
multi.go | 5 years ago | |
nodb.go | 5 years ago | |
nodb_db.go | 5 years ago | |
replication.go | 5 years ago | |
scan.go | 5 years ago | |
t_bit.go | 5 years ago | |
t_hash.go | 5 years ago | |
t_kv.go | 5 years ago | |
t_list.go | 5 years ago | |
t_set.go | 5 years ago | |
t_ttl.go | 5 years ago | |
t_zset.go | 5 years ago | |
tx.go | 5 years ago | |
util.go | 5 years ago |
Nodb is a fork of ledisdb and shrink version. It's get rid of all C or other language codes and only keep Go's. It aims to provide a nosql database library rather than a redis like server. So if you want a redis like server, ledisdb is the best choose.
Nodb is a pure Go and high performance NoSQL database library. It supports some data structure like kv, list, hash, zset, bitmap, set.
Nodb now use goleveldb as backend to store data.
go get github.com/lunny/nodb
import(
"github.com/lunny/nodb"
"github.com/lunny/nodb/config"
)
cfg := new(config.Config)
cfg.DataDir = "./"
dbs, err := nodb.Open(cfg)
if err != nil {
fmt.Printf("nodb: error opening db: %v", err)
}
db, _ := dbs.Select(0)
KV is the most basic nodb type like any other key-value database.
err := db.Set(key, value)
value, err := db.Get(key)
List is simply lists of values, sorted by insertion order. You can push or pop value on the list head (left) or tail (right).
err := db.LPush(key, value1)
err := db.RPush(key, value2)
value1, err := db.LPop(key)
value2, err := db.RPop(key)
Hash is a map between fields and values.
n, err := db.HSet(key, field1, value1)
n, err := db.HSet(key, field2, value2)
value1, err := db.HGet(key, field1)
value2, err := db.HGet(key, field2)
ZSet is a sorted collections of values. Every member of zset is associated with score, a int64 value which used to sort, from smallest to greatest score. Members are unique, but score may be same.
n, err := db.ZAdd(key, ScorePair{score1, member1}, ScorePair{score2, member2})
ay, err := db.ZRangeByScore(key, minScore, maxScore, 0, -1)
Gmail: siddontang@gmail.com