一个 Redka 客户端,使用体验更像在使用 Redis 客户端。
- Strings 命令
- Lists 命令
- Sets 命令
- Hashes 命令
- Sorted sets 命令
- Key 命令
- Server/Connection 命令
- Transations 命令
Redka Client 要求 Go 版本 1.22 或以上。
import "github.com/hugiot/redkacli"或者
go get -u github.com/hugiot/redkaclipackage main
import (
"fmt"
"github.com/hugiot/redkacli"
"log"
)
func main() {
options := redkacli.NewOptions()
options.SetPath("./test.db")
client, err := redkacli.New(options)
if err != nil {
log.Fatal(err)
}
defer client.Close()
// string commands
_ = client.Set("name", "Tom")
fmt.Println(client.Get("name"))
// hash commands
_, _ = client.HSet("object", map[string]interface{}{
"name": "Tom",
"age": 10,
"city": "New York",
})
fmt.Println(client.HGetAll("object"))
// other commands
// ……
}