0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-12-29 02:44:08 -05:00
forgejo/vendor/gitea.com/lunny/nodb
6543 70ea2300ca
[Vendor] update macaron related (#13409)
* Vendor: update gitea.com/macaron/session to a177a270

* make vendor

* Vendor: update gitea.com/macaron/macaron to 0db5d458

* make vendor

* Vendor: update gitea.com/macaron/cache to 905232fb

* make vendor

* Vendor: update gitea.com/macaron/i18n to 4ca3dd0c

* make vendor

* Vendor: update gitea.com/macaron/gzip to efa5e847

* make vendor

* Vendor: update gitea.com/macaron/captcha to e8597820

* make vendor
2020-11-03 08:04:09 +02:00
..
config [Vendor] update macaron related (#13409) 2020-11-03 08:04:09 +02:00
store [Vendor] update macaron related (#13409) 2020-11-03 08:04:09 +02:00
.gitignore [Vendor] update macaron related (#13409) 2020-11-03 08:04:09 +02:00
batch.go [Vendor] update macaron related (#13409) 2020-11-03 08:04:09 +02:00
binlog.go [Vendor] update macaron related (#13409) 2020-11-03 08:04:09 +02:00
binlog_util.go [Vendor] update macaron related (#13409) 2020-11-03 08:04:09 +02:00
const.go [Vendor] update macaron related (#13409) 2020-11-03 08:04:09 +02:00
doc.go [Vendor] update macaron related (#13409) 2020-11-03 08:04:09 +02:00
dump.go [Vendor] update macaron related (#13409) 2020-11-03 08:04:09 +02:00
go.mod [Vendor] update macaron related (#13409) 2020-11-03 08:04:09 +02:00
go.sum [Vendor] update macaron related (#13409) 2020-11-03 08:04:09 +02:00
info.go [Vendor] update macaron related (#13409) 2020-11-03 08:04:09 +02:00
LICENSE [Vendor] update macaron related (#13409) 2020-11-03 08:04:09 +02:00
multi.go [Vendor] update macaron related (#13409) 2020-11-03 08:04:09 +02:00
nodb.go [Vendor] update macaron related (#13409) 2020-11-03 08:04:09 +02:00
nodb_db.go [Vendor] update macaron related (#13409) 2020-11-03 08:04:09 +02:00
README.md [Vendor] update macaron related (#13409) 2020-11-03 08:04:09 +02:00
README_CN.md [Vendor] update macaron related (#13409) 2020-11-03 08:04:09 +02:00
replication.go [Vendor] update macaron related (#13409) 2020-11-03 08:04:09 +02:00
scan.go [Vendor] update macaron related (#13409) 2020-11-03 08:04:09 +02:00
t_bit.go [Vendor] update macaron related (#13409) 2020-11-03 08:04:09 +02:00
t_hash.go [Vendor] update macaron related (#13409) 2020-11-03 08:04:09 +02:00
t_kv.go [Vendor] update macaron related (#13409) 2020-11-03 08:04:09 +02:00
t_list.go [Vendor] update macaron related (#13409) 2020-11-03 08:04:09 +02:00
t_set.go [Vendor] update macaron related (#13409) 2020-11-03 08:04:09 +02:00
t_ttl.go [Vendor] update macaron related (#13409) 2020-11-03 08:04:09 +02:00
t_zset.go [Vendor] update macaron related (#13409) 2020-11-03 08:04:09 +02:00
tx.go [Vendor] update macaron related (#13409) 2020-11-03 08:04:09 +02:00
util.go [Vendor] update macaron related (#13409) 2020-11-03 08:04:09 +02: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