1 回答

TA貢獻2051條經驗 獲得超10個贊
網上有很多例子。但是,我總是會參考官方文檔。
請參閱此處的文檔:https ://github.com/robaho/keydb和https://pkg.go.dev/github.com/robaho/keydb
如何使用 :
db, err := keydb.Open("test/mydb", true)
if err != nil {
t.Fatal("unable to create database", err)
}
tx, err := db.BeginTX("main")
if err != nil {
t.Fatal("unable to create transaction", err)
}
err = tx.Put([]byte("mykey"), []byte("myvalue"))
if err != nil {
t.Fatal("unable to put key/Value", err)
}
err = tx.Commit()
if err != nil {
t.Fatal("unable to commit transaction", err)
}
err = db.Close()
if err != nil {
t.Fatal("unable to close database", err)
}
網上有很多例子,請參考: https ://golang.hotexamples.com/examples/github.com.endophage.gotuf.keys/KeyDB/-/golang-keydb-class-examples.html
此外,如何從 keydb 遷移到 redis,反之亦然,請參閱此鏈接: https ://docs.keydb.dev/docs/migration/
- 1 回答
- 0 關注
- 168 瀏覽
添加回答
舉報