go-redis v8 XAutoClaim is not compatible with Redis server v7+

王林
Release: 2024-02-09 16:54:08
forward
875 people have browsed it

go-redis v8 XAutoClaim 与 Redis 服务器 v7+ 不兼容

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.

Question content

Question

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.

Steps to reproduce

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())
Copy after login

Solution

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!

source:stackoverflow.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!