用于Go語言的KV數據庫:GobDB
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()
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!