Having issue migrating from go-redis to valkey-go #797
-
Currently we have used : What will be the compatible code for above two in valkey-go? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 21 replies
-
I don't know the answer to your question, but I know valkey-go is a fork of rueidis, not of go-redis. (Though there are discussions about forking go-redis too.) @rueian FYI |
Beta Was this translation helpful? Give feedback.
-
The compatible code will be using valkeycompat: package main
import (
"context"
"time"
"github.com/valkey-io/valkey-go"
"github.com/valkey-io/valkey-go/valkeycompat"
)
func main() {
ctx := context.Background()
client, err := valkey.NewClient(valkey.ClientOption{InitAddress: []string{"127.0.0.1:6379"}})
if err != nil {
panic(err)
}
defer client.Close()
compat := valkeycompat.NewAdapter(client)
ok, _ := compat.SetNX(ctx, "key", "val", time.Second).Result()
// with client side caching
res, _ := compat.Cache(time.Second).Get(ctx, "key").Result()
} The adapter is compatible with UniversalClient. https://github.com/valkey-io/valkey-go/tree/main/valkeycompat |
Beta Was this translation helpful? Give feedback.
Hi all,
The
Pipeliner
,Tx
,Nil
,Script
, andWatch
are all available in the 1.0.44. Please refer to the https://github.com/valkey-io/valkey-go/blob/main/valkeycompat/README.md for more examples.