用于Go语言的KV数据库:GobDB

jopen 9年前

GobDB是一个简单的数据库,专门优化用于Go应用开发。它对 leveldb 进行了封装提供了 gob兼容类型的持久key-value存储。

Setup a database and assign a local data file.

db := GobDB.At("example")  db.Open()

Insert persistently key-value pairs. We use strings here, but all gob-compatible values are supported.

db.Put("name", "adam")

Fetch values of key-value pairs. Note that you must provide a pointer of the correct type.

var value string = ""  db.Get("name", &value)

Check if keys are contained within the database.

db.Has("name")  db.Has("3234") 

Close the database and write changes to disk.

db.Close()

项目主页:http://www.open-open.com/lib/view/home/1413854066122