Shota
Shota

Reputation: 11

Golang how to get started with KEYDB

I started studying the question of how to replace REDIS and found descriptions of the KEYDB database, but I did not find a description of how to start using it with Golang, if there are examples or who knows where to read, please share information.

Upvotes: -1

Views: 1376

Answers (1)

Ashutosh Singh
Ashutosh Singh

Reputation: 1072

There are many example present over the internet. But, I would refer the official docs always.

Refer docs here : https://github.com/robaho/keydb and https://pkg.go.dev/github.com/robaho/keydb

How to use :

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)
}

Many example present over the net please refer this : https://golang.hotexamples.com/examples/github.com.endophage.gotuf.keys/KeyDB/-/golang-keydb-class-examples.html

Also how to migrate from keydb to redis and vise versa refer this link : https://docs.keydb.dev/docs/migration/

Upvotes: -1

Related Questions