A pure Go embed Nosql database with kv, list, hash, zset, bitmap, set.
This repository has been archived on 2020-09-23. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
techknowlogick 3238c46557 switch to spec compliant toml lib (#9)
switch to spec compliant toml lib

Co-authored-by: Matti R <matti@mdranta.net>
Reviewed-on: #9
2020-09-23 03:23:08 +00:00
config switch to spec compliant toml lib (#9) 2020-09-23 03:23:08 +00:00
store upate refs. 2019-11-01 09:27:28 +08:00
tools init 2014-09-17 22:07:07 +08:00
.gitignore added iterator 2016-05-08 13:08:20 +08:00
batch.go upate refs. 2019-11-01 09:27:28 +08:00
binlog_test.go upate refs. 2019-11-01 09:27:28 +08:00
binlog_util.go init 2014-09-17 22:07:07 +08:00
binlog.go upate refs. 2019-11-01 09:27:28 +08:00
const.go add version 2015-02-10 14:56:08 +08:00
doc.go doc improved 2014-09-18 13:06:40 +08:00
dump_test.go upate refs. 2019-11-01 09:27:28 +08:00
dump.go init 2014-09-17 22:07:07 +08:00
go.mod switch to spec compliant toml lib (#9) 2020-09-23 03:23:08 +00:00
go.sum switch to spec compliant toml lib (#9) 2020-09-23 03:23:08 +00:00
info.go init 2014-09-17 22:07:07 +08:00
LICENSE init 2014-09-17 22:07:07 +08:00
multi_test.go init 2014-09-17 22:07:07 +08:00
multi.go init 2014-09-17 22:07:07 +08:00
nodb_db.go upate refs. 2019-11-01 09:27:28 +08:00
nodb_test.go upate refs. 2019-11-01 09:27:28 +08:00
nodb.go move github.com/lunny/log -> gitea.com/lunny/log 2019-11-09 17:05:17 +08:00
README_CN.md fix refs 2019-11-01 10:48:30 +08:00
README.md fix refs 2019-11-01 10:48:30 +08:00
replication_test.go upate refs. 2019-11-01 09:27:28 +08:00
replication.go move github.com/lunny/log -> gitea.com/lunny/log 2019-11-09 17:05:17 +08:00
scan_test.go init 2014-09-17 22:07:07 +08:00
scan.go upate refs. 2019-11-01 09:27:28 +08:00
t_bit_test.go init 2014-09-17 22:07:07 +08:00
t_bit.go upate refs. 2019-11-01 09:27:28 +08:00
t_hash_test.go init 2014-09-17 22:07:07 +08:00
t_hash.go upate refs. 2019-11-01 09:27:28 +08:00
t_kv_test.go init 2014-09-17 22:07:07 +08:00
t_kv.go added lock 2016-06-21 09:51:57 +08:00
t_list_test.go init 2014-09-17 22:07:07 +08:00
t_list.go upate refs. 2019-11-01 09:27:28 +08:00
t_set_test.go init 2014-09-17 22:07:07 +08:00
t_set.go upate refs. 2019-11-01 09:27:28 +08:00
t_ttl_test.go tests 2014-12-27 10:27:58 +08:00
t_ttl.go upate refs. 2019-11-01 09:27:28 +08:00
t_zset_test.go upate refs. 2019-11-01 09:27:28 +08:00
t_zset.go upate refs. 2019-11-01 09:27:28 +08:00
tx_test.go init 2014-09-17 22:07:07 +08:00
tx.go upate refs. 2019-11-01 09:27:28 +08:00
util.go init 2014-09-17 22:07:07 +08:00

NoDB

中文

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.

Features

  • Rich data structure: KV, List, Hash, ZSet, Bitmap, Set.
  • Stores lots of data, over the memory limit.
  • Supports expiration and ttl.
  • Easy to embed in your own Go application.

Install

go get gitea.com/lunny/nodb

Package Example

Open And Select database

import(
  "gitea.com/lunny/nodb"
  "gitea.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

KV is the most basic nodb type like any other key-value database.

err := db.Set(key, value)
value, err := db.Get(key)

List

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

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

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)

Thanks

Gmail: siddontang@gmail.com