Categorygithub.com/dicedb/dicedb-go
modulepackage
0.1.1
Repository: https://github.com/dicedb/dicedb-go.git
Documentation: pkg.go.dev

# README

go-dice

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.

Features

  • 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.

Get started

Installation

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

Quickstart

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.

Setting up repository from source for development and contributions

To run go-dice for local development or running from source, you will need:

  1. Golang
  2. Any of the below supported platform environment:
    1. Linux based environment
    2. OSX (Darwin) based environment
    3. WSL under Windows
$ git clone https://github.com/dicedb/dicedb-go.git
$ cd go-dice

How to contribute

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.

License

go-dice is licensed under the MIT License. See the LICENSE file for more details.

# Packages

No description provided by the author

# Functions

No description provided by the author
No description provided by the author
HasErrorPrefix checks if the err is a Redis error and the message contains a prefix.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewBoolResult returns a BoolCmd initialised with val and err for testing.
No description provided by the author
NewBoolSliceResult returns a BoolSliceCmd initialised with val and err for testing.
No description provided by the author
NewClient returns a client to the Redis Server specified by Options.
No description provided by the author
NewClusterClient returns a Redis Cluster client as described in http://redis.io/topics/cluster-spec.
No description provided by the author
No description provided by the author
No description provided by the author
NewClusterSlotsCmdResult returns a ClusterSlotsCmd initialised with val and err for testing.
No description provided by the author
NewCmdResult returns a Cmd initialised with val and err for testing.
No description provided by the author
No description provided by the author
NewCommandsInfoCmdResult returns a CommandsInfoCmd initialised with val and err for testing.
NewDialer returns a function that will be used as the default dialer when none is specified in Options.Dialer.
No description provided by the author
NewDurationResult returns a DurationCmd initialised with val and err for testing.
NewFailoverClient returns a Redis client that uses Redis Sentinel for automatic failover.
NewFailoverClusterClient returns a client that supports routing read-only commands to a replica node.
No description provided by the author
NewFloatResult returns a FloatCmd initialised with val and err for testing.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewGeoLocationCmdResult returns a GeoLocationCmd initialised with val and err for testing.
No description provided by the author
NewGeoPosCmdResult returns a GeoPosCmd initialised with val and err for testing.
No description provided by the author
No description provided by the author
No description provided by the author
NewIntPointerSliceCmd initialises an IntPointerSliceCmd.
NewIntResult returns an IntCmd initialised with val and err for testing.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewMapStringIntCmdResult returns a MapStringIntCmd initialised with val and err for testing.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewMapStringStringResult returns a MapStringStringCmd initialised with val and err for testing.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewScanCmdResult returns a ScanCmd initialised with val and err for testing.
No description provided by the author
No description provided by the author
No description provided by the author
NewSliceResult returns a SliceCmd initialised with val and err for testing.
No description provided by the author
No description provided by the author
NewStatusResult returns a StatusCmd initialised with val and err for testing.
No description provided by the author
NewStringResult returns a StringCmd initialised with val and err for testing.
No description provided by the author
NewStringSliceResult returns a StringSliceCmd initialised with val and err for testing.
No description provided by the author
No description provided by the author
No description provided by the author
NewTimeCmdResult returns a TimeCmd initialised with val and err for testing.
No description provided by the author
NewUniversalClient returns a new multi client.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewXMessageSliceCmdResult returns a XMessageSliceCmd initialised with val and err for testing.
No description provided by the author
No description provided by the author
NewXPendingResult returns a XPendingCmd initialised with val and err for testing.
No description provided by the author
NewXStreamSliceCmdResult returns a XStreamSliceCmd initialised with val and err for testing.
No description provided by the author
NewZSliceCmdResult returns a ZSliceCmd initialised with val and err for testing.
No description provided by the author
No description provided by the author
NewZWithKeyCmdResult returns a ZWithKeyCmd initialised with val and err for testing.
ParseClusterURL parses a URL into ClusterOptions that can be used to connect to Redis.
ParseURL parses a URL into Options that can be used to connect to Redis.
No description provided by the author
SetLogger set custom log.
Version is the current release version.
WithChannelHealthCheckInterval specifies the health check interval.
WithChannelSendTimeout specifies the channel send timeout after which the message is dropped.
WithChannelSize specifies the Go chan size that is used to buffer incoming messages.
WithLibraryName returns a valid LibraryInfo with library name only.
WithLibraryVersion returns a valid LibraryInfo with library version only.
WithQChannelHealthCheckInterval specifies the health check interval.
WithQChannelSendTimeout specifies the timeout for sending messages to the Go channel.
WithQChannelSize specifies the size of the Go channel buffer.
WithWChannelHealthCheckInterval specifies the health check interval.
WithWChannelSendTimeout specifies the timeout for sending messages to the Go channel.
WithWChannelSize specifies the size of the Go channel buffer.

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
Client used by RM_Call is allowed to fully execute scripts even when in OOM */.
Client issued the ASKING command */.
The client is waiting in a blocking operation */.
Close after executing commands * and writing entire reply.
Close after writing entire reply.
Close this client ASAP */.
Indicate that the client should not be blocked.
Watched keys modified.
EXEC will fail for errors while queueing */.
Indicates that the client is currently in the process of handling a command.
Force AOF propagation of current cmd.
Force replication of current cmd.
This client is in the timeout table.
Run EVAL in debug mode.
EVAL debugging without fork() */.
This client is a master */.
Queue replies even if is master */.
Non connected client used by some module.
This client is a slave monitor, see MONITOR */.
This client is in a MULTI context */.
This client is protected against client memory eviction.
This client will not touch LFU/LRU stats.
Indicates the client has a fully * parsed command ready for execution.
Client has output to send but a-write handler is yet not installed.
Instance don't understand PSYNC.
Don't propagate to AOF.
No description provided by the author
Don't propagate to slaves.
Client should not be freed for now.
Protocol error chatting with it.
Client is in Pub/Sub mode.
This client is pushing notifications.
Cluster client is in read-only state.
This client is a replica that only wants RDB without replication buffer.
Don't send replies to client.
Don't send just this reply.
Set ClientREPLY_SKIP for next cmd */.
This is a non-connected client used by Lua */.
This client is a replica */.
Client enabled keys tracking in order to perform client side caching.
Tracking in BCAST mode.
Target client is invalid.
CACHING yes/no was given, depending on optin/optout mode.
Don't send invalidation messages about writes performed by myself.*/.
Tracking in opt-in mode.
Tracking in opt-out mode.
This client was unblocked and is stored in server.unblocked_clients */.
Client connected via Unix domain socket */.
No description provided by the author
No description provided by the author
No description provided by the author
KeepTTL is a Redis KEEPTTL option to keep existing TTL, it requires your redis-server version >= 6.0, otherwise you will receive an error: (error) ERR syntax error.
No description provided by the author
No description provided by the author
No description provided by the author
Nil reply returned by Redis when key does not exist.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
TxFailedErr transaction redis failed.
No description provided by the author
No description provided by the author

# Variables

ErrClosed performs any operation on the closed client will return this error.

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Client is a Redis client representing a pool of zero or more underlying connections.
ClientInfo is redis-server ClientInfo, not go-redis *Client.
No description provided by the author
ClusterClient is a Redis Cluster client representing a pool of zero or more underlying connections.
No description provided by the author
No description provided by the author
No description provided by the author
ClusterOptions are used to configure a cluster client and should be passed to NewClusterClient.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Conn represents a single Redis connection rather than a pool of connections.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
FailoverOptions are used to configure a failover client and should be passed to NewFailoverClient.
No description provided by the author
No description provided by the author
FilterBy is used for the `CommandList` command parameter.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Each AggregateReducer have different args.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
FunctionListQuery is used with FunctionList to query for Redis libraries LibraryNamePattern - Use an empty string to get all libraries.
FunctionStats contains information about the scripts currently executing on the server, and the available engines - Engines: Statistics about the engine like number of functions and number of libraries - RunningScript: The script currently running on the shard we're connecting to.
No description provided by the author
No description provided by the author
GeoLocation is used with GeoAdd to add geospatial location.
No description provided by the author
No description provided by the author
No description provided by the author
GeoRadiusQuery is used with GeoRadius to query geospatial index.
No description provided by the author
No description provided by the author
GeoSearchQuery is used for GEOSearch/GEOSearchStore command query.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
KV represents a key-value pair.
No description provided by the author
LCSMatch is the result set of the LCS command.
No description provided by the author
No description provided by the author
LCSQuery is a parameter used for the LCS command.
No description provided by the author
LibraryInfo holds the library info.
No description provided by the author
----------------------------------------------------------------------- MapStringInterfaceCmd represents a command that returns a map of strings to interface{}.
No description provided by the author
No description provided by the author
No description provided by the author
------------------------------------------------------------------------------.
No description provided by the author
No description provided by the author
Message received as result of a PUBLISH command issued by another client.
ModuleLoadexConfig struct is used to specify the arguments for the MODULE LOADEX command of redis.
No description provided by the author
No description provided by the author
Options keeps the settings to set up redis connection.
Pipeline implements pipelining as described in http://redis.io/topics/pipelining.
Pong received as result of a PING command issued by another client.
PubSub implements Pub/Sub commands as described in http://redis.io/topics/pubsub.
QMessage represents a message received via QWATCH.
QWatch implements the QWATCH command, which allows clients to watch queries.
No description provided by the author
No description provided by the author
Ring is a Redis client that uses consistent hashing to distribute keys across multiple Redis servers (shards).
RingOptions are used to configure a ring client and should be passed to NewRing.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ScanIterator is used to incrementally iterate over a collection of elements.
No description provided by the author
SentinelClient is a client for a Redis Sentinel.
SetArgs provides arguments for the SetArgs function.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Subscription received after a successful subscription to channel.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Tx implements Redis transactions as described in http://redis.io/topics/transactions.
UniversalOptions information is required by UniversalClient to establish connections.
WatchConn implements the WATCHCOMMAND, which allows clients to watch commands.
WatchResult represents a message received via WatchConn.
XAddArgs accepts values in the following formats: - XAddArgs.Values = []interface{}{"key1", "value1", "key2", "value2"} - XAddArgs.Values = []string("key1", "value1", "key2", "value2") - XAddArgs.Values = map[string]interface{}{"key1": "value1", "key2": "value2"} Note that map will not preserve the order of key-value pairs.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Z represents sorted set member.
ZAddArgs WARN: The GT, LT and NX options are mutually exclusive.
ZRangeArgs is all the options of the ZRange command.
No description provided by the author
No description provided by the author
No description provided by the author
ZStore is used as an arg to ZInter/ZInterStore and ZUnion/ZUnionStore.
ZWithKey represents sorted set member including the name of the key where it was popped.
No description provided by the author

# Interfaces

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Limiter is the interface of a rate limiter or a circuit breaker.
No description provided by the author
Pipeliner is an mechanism to realise Redis Pipeline technique.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
UniversalClient is an abstract client which - based on the provided options - represents either a ClusterClient, a FailoverClient, or a single-node Client.

# Type aliases

No description provided by the author
No description provided by the author
No description provided by the author
ClientFlags is redis-server client flags, copy from redis/src/server.h (redis 7.0).
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
QChannelOption configures a qChannel.
Scanner internal/hscan.Scanner exposed interface.
No description provided by the author
No description provided by the author
No description provided by the author
WChannelOption configures a wChannel.