go-dice
is a high-performance, fully-featured Go client designed specifically for interacting with DiceDB, a powerful, distributed in-memory database.
This library allows Go developers to easily connect to DiceDB, execute commands, and manage their data efficiently.
As a fork of go-redis client, go-dice maintains compatibility with DiceDB's extended features, including native support for DiceDB commands and operations.
- Seamless integration with DiceDB’s extended command set.
- Fully extensible to support DiceDB’s unique data structures.
- Optimized for high-performance and large-scale applications.
- Easy-to-use APIs for common operations like string manipulation, set operations, and more.
To install go-dice
in your Go project, you can use go get to fetch the library:
go get github.com/dicedb/dicedb-go
After installing, you can import the library into your project:
import (
"github.com/dicedb/dicedb-go"
)
package main
import (
"context"
"fmt"
"log"
"github.com/dicedb/dicedb-go"
)
func main() {
// Create a new DiceDB client
client := dicedb.NewClient(&dicedb.Options{
Addr: "localhost:7379", // Replace with your DiceDB server address
Password: "", // No password set
DB: 0, // Use default DB
})
// Use context for operations
ctx := context.Background()
// Set a key-value pair
err := client.Set(ctx, "key", "value", 0).Err()
if err != nil {
log.Fatalf("Failed to set key: %v", err)
}
// Retrieve the value of the key
val, err := client.Get(ctx, "key").Result()
if err != nil {
log.Fatalf("Failed to get key: %v", err)
}
fmt.Printf("key: %s\n", val)
// Close the client connection when done
err = client.Close()
if err != nil {
log.Fatalf("Error closing the client: %v", err)
}
}
This basic example demonstrates how you can interact with DiceDB using go-dice
. You can explore more advanced usage by referring to the DiceDB Documentation.
You can also refer examples here implement truly real-time applications like Leaderboard with simple SQL query.
To run go-dice
for local development or running from source, you will need:
- Golang
- Any of the below supported platform environment:
- Linux based environment
- OSX (Darwin) based environment
- WSL under Windows
$ git clone https://github.com/dicedb/dicedb-go.git
$ cd go-dice
The Code Contribution Guidelines are published at CONTRIBUTING.md; please read them before you start making any changes. This would allow us to have a consistent standard of coding practices and developer experience.
Contributors can join the Discord Server for quick collaboration.
go-dice
is licensed under the MIT License. See the LICENSE file for more details.