Command Comparison Chart
Below is a comprehensive chart comparing common Valkey commands between go-redis and Valkey GLIDE:
Connection
Section titled “Connection”| Command | go-redis | Valkey GLIDE |
|---|---|---|
| Connect | redis.NewClient(&redis.Options{Addr: "localhost:6379"}) | glide.NewClient(&config.ClientConfiguration{Addresses: []config.NodeAddress{{Host: "localhost", Port: 6379}}}) |
| Cluster | redis.NewClusterClient(&redis.ClusterOptions{Addrs: []string{"127.0.0.1:6379"}}) | glide.NewClusterClient(&config.ClusterClientConfiguration{Addresses: []config.NodeAddress{{Host: "127.0.0.1", Port: 6379}}}) |
| Auth | rdb.Auth(ctx, "password") | Set in config.ServerCredentials{Password: "password"} during connection |
| Select DB | rdb.Select(ctx, 1) | Set DatabaseId: 1 in configuration |
Strings
Section titled “Strings”| Command | go-redis | Valkey GLIDE |
|---|---|---|
| SET | rdb.Set(ctx, "key", "val", 0) | client.Set(ctx, "key", "val") |
| GET | rdb.Get(ctx, "key") | client.Get(ctx, "key") |
| SETEX | rdb.SetEx(ctx, "key", "val", time.Hour) | client.SetWithOptions(ctx, "key", "val", options.SetOptions{Expiry: &options.Expiry{Type: options.Seconds, Count: 3600}}) |
| SETNX | rdb.SetNX(ctx, "key", "val", 0) | client.SetWithOptions(ctx, "key", "val", options.SetOptions{ConditionalSet: options.OnlyIfDoesNotExist}) |
| MSET | rdb.MSet(ctx, map[string]interface{}{"k1": "v1"}) | client.MSet(ctx, map[string]string{"k1": "v1"}) |
| MGET | rdb.MGet(ctx, "key1", "key2") | client.MGet(ctx, []string{"key1", "key2"}) |
| INCR | rdb.Incr(ctx, "counter") | client.Incr(ctx, "counter") |
| DECR | rdb.Decr(ctx, "counter") | client.Decr(ctx, "counter") |
| INCRBY | rdb.IncrBy(ctx, "counter", 5) | client.IncrBy(ctx, "counter", 5) |
| DECRBY | rdb.DecrBy(ctx, "counter", 5) | client.DecrBy(ctx, "counter", 5) |
| APPEND | rdb.Append(ctx, "key", "val") | client.Append(ctx, "key", "val") |
| GETRANGE | rdb.GetRange(ctx, "key", 0, 3) | client.GetRange(ctx, "key", 0, 3) |
| SETRANGE | rdb.SetRange(ctx, "key", 0, "val") | client.SetRange(ctx, "key", 0, "val") |
| Command | go-redis | Valkey GLIDE |
|---|---|---|
| DEL | rdb.Del(ctx, "key1", "key2") | client.Del(ctx, []string{"key1", "key2"}) |
| EXISTS | rdb.Exists(ctx, "key1", "key2") | client.Exists(ctx, []string{"key1", "key2"}) |
| EXPIRE | rdb.Expire(ctx, "key", 10*time.Second) | client.Expire(ctx, "key", 10*time.Second) |
| TTL | rdb.TTL(ctx, "key") | client.TTL(ctx, "key") |
| KEYS | rdb.Keys(ctx, "pattern") | client.Keys(ctx, "pattern") |
| SCAN | rdb.Scan(ctx, cursor, "*", 10) | client.Scan(ctx, cursor) |
| RENAME | rdb.Rename(ctx, "old", "new") | client.Rename(ctx, "old", "new") |
| RENAMENX | rdb.RenameNX(ctx, "old", "new") | client.RenameNX(ctx, "old", "new") |
Hashes
Section titled “Hashes”| Command | go-redis | Valkey GLIDE |
|---|---|---|
| HSET | rdb.HSet(ctx, "hash", "k1", "v1", "k2", "v2") | client.HSet(ctx, "hash", map[string]string{"k1": "v1", "k2": "v2"}) |
| HGET | rdb.HGet(ctx, "hash", "field") | client.HGet(ctx, "hash", "field") |
| HMSET | rdb.HMSet(ctx, "hash", map[string]interface{}{"k1": "v1"}) | client.HSet(ctx, "hash", map[string]string{"k1": "v1"}) |
| HMGET | rdb.HMGet(ctx, "hash", "k1", "k2") | client.HMGet(ctx, "hash", []string{"k1", "k2"}) |
| HGETALL | rdb.HGetAll(ctx, "hash") | client.HGetAll(ctx, "hash") |
| HDEL | rdb.HDel(ctx, "hash", "k1", "k2") | client.HDel(ctx, "hash", []string{"k1", "k2"}) |
| HEXISTS | rdb.HExists(ctx, "hash", "field") | client.HExists(ctx, "hash", "field") |
| Command | go-redis | Valkey GLIDE |
|---|---|---|
| LPUSH | rdb.LPush(ctx, "list", "a", "b") | client.LPush(ctx, "list", []string{"a", "b"}) |
| RPUSH | rdb.RPush(ctx, "list", "a", "b") | client.RPush(ctx, "list", []string{"a", "b"}) |
| LPOP | rdb.LPop(ctx, "list") | client.LPop(ctx, "list") |
| RPOP | rdb.RPop(ctx, "list") | client.RPop(ctx, "list") |
| LRANGE | rdb.LRange(ctx, "list", 0, -1) | client.LRange(ctx, "list", 0, -1) |
| Command | go-redis | Valkey GLIDE |
|---|---|---|
| SADD | rdb.SAdd(ctx, "set", "a", "b") | client.SAdd(ctx, "set", []string{"a", "b"}) |
| SMEMBERS | rdb.SMembers(ctx, "set") | client.SMembers(ctx, "set") |
| SREM | rdb.SRem(ctx, "set", "a", "b") | client.SRem(ctx, "set", []string{"a", "b"}) |
| SISMEMBER | rdb.SIsMember(ctx, "set", "a") | client.SIsMember(ctx, "set", "a") |
Sorted Sets
Section titled “Sorted Sets”| Command | go-redis | Valkey GLIDE |
|---|---|---|
| ZADD | rdb.ZAdd(ctx, "zset", redis.Z{Score: 1, Member: "a"}, redis.Z{Score: 2, Member: "b"}) | client.ZAdd(ctx, "zset", map[string]float64{"a": 1.0, "b": 2.0}) |
| ZRANGE | rdb.ZRange(ctx, "zset", 0, -1) | client.ZRange(ctx, "zset", options.RangeByIndex{Start: 0, End: -1}) |
| ZRANGE with scores | rdb.ZRangeWithScores(ctx, "zset", 0, -1) | client.ZRangeWithScores(ctx, "zset", options.RangeByIndex{Start: 0, End: -1}) |
| ZREM | rdb.ZRem(ctx, "zset", "a", "b") | client.ZRem(ctx, "zset", []string{"a", "b"}) |
| ZSCORE | rdb.ZScore(ctx, "zset", "a") | client.ZScore(ctx, "zset", "a") |
| ZRANK | rdb.ZRank(ctx, "zset", "a") | client.ZRank(ctx, "zset", "a") |
| ZREVRANK | rdb.ZRevRank(ctx, "zset", "a") | client.ZRevRank(ctx, "zset", "a") |
Transactions
Section titled “Transactions”| Command | go-redis | Valkey GLIDE |
|---|---|---|
| MULTI/EXEC | pipe := rdb.TxPipeline(); pipe.Set(ctx, "k", "v", 0); pipe.Get(ctx, "k"); pipe.Exec(ctx) | batch := pipeline.NewStandaloneBatch(); batch.Set("k", "v"); batch.Get("k"); client.Exec(ctx, batch, false) |
Lua Scripts
Section titled “Lua Scripts”| Command | go-redis | Valkey GLIDE |
|---|---|---|
| EVAL | rdb.Eval(ctx, script, []string{"key"}, "arg") | client.InvokeScriptWithOptions(ctx, options.NewScript(script), options.ScriptOptions{Keys: []string{"key"}, Args: []string{"arg"}}) |
| EVALSHA | rdb.EvalSha(ctx, sha, []string{"key"}, "arg") | client.InvokeScriptWithOptions(ctx, options.NewScript(script), options.ScriptOptions{Keys: []string{"key"}, Args: []string{"arg"}}) |
Custom Commands
Section titled “Custom Commands”| Command | go-redis | Valkey GLIDE |
|---|---|---|
| Raw Command | rdb.Do(ctx, "SET", "key", "value") | client.CustomCommand(ctx, []string{"SET", "key", "value"}) |
Connection Management
Section titled “Connection Management”| Command | go-redis | Valkey GLIDE |
|---|---|---|
| Close | rdb.Close() | client.Close() |