php editor Zimo is here to introduce to you an important issue, that is, the XAutoClaim function of go-redis v8 is incompatible with Redis server v7. It is understood that go-redis is a popular Golang Redis client library, and XAutoClaim is a new feature in its latest version, which can be used to automatically allocate tasks in the Redis queue. However, when using this function, it was found that it was incompatible with Redis server v7, causing it to not work properly. This problem may cause some trouble to developers using go-redis, so we need to find a solution to solve this compatibility issue.
I'm using go-redis v8 with a redis v7 server instance. As far as I know, the XAutoClaim
command is not compatible.
client.XAutoClaim
Returned error: got 3, wanted 2
.
The official go-redis/v8 documentation on XAutoClaim makes no mention of incompatibility with redis version 7.
ctx := context.Background() streamName := "test-stream" groupName := "test-group" rdb := redis.NewClient(&redis.Options{ Addr: "localhost:6379", Password: "", // no password set DB: 0, // use default DB }) defer rdb.FlushDB(ctx).Err() // Add message to stream rdb.XAdd(ctx, &redis.XAddArgs{ Stream: streamName, Values: map[string]interface{}{"key": "value"}, }) // Create consumer group rdb.XGroupCreateMkStream(ctx, streamName, groupName, "0") autoclaimError := rdb.XAutoClaim(ctx, &redis.XAutoClaimArgs{ Stream: streamName, Group: groupName, Consumer: "test-consumer", MinIdle: 0, Start: "-", Count: 1, }).Err() print(autoclaimError.Error())
go-redis v8 XAutoClaim is not compatible with Redis version 7. Although this issue is not officially documented, there is an issue about it here: https:///github.com/redis/go-redis/issues/2106.
The above is the detailed content of go-redis v8 XAutoClaim is not compatible with Redis server v7+. For more information, please follow other related articles on the PHP Chinese website!