Table of Contents
Question content
Question
Steps to reproduce
Solution
Home Backend Development Golang go-redis v8 XAutoClaim is not compatible with Redis server v7+

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

Feb 09, 2024 pm 04:54 PM

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!

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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Go language pack import: What is the difference between underscore and without underscore? Go language pack import: What is the difference between underscore and without underscore? Mar 03, 2025 pm 05:17 PM

Go language pack import: What is the difference between underscore and without underscore?

How to implement short-term information transfer between pages in the Beego framework? How to implement short-term information transfer between pages in the Beego framework? Mar 03, 2025 pm 05:22 PM

How to implement short-term information transfer between pages in the Beego framework?

How do I write mock objects and stubs for testing in Go? How do I write mock objects and stubs for testing in Go? Mar 10, 2025 pm 05:38 PM

How do I write mock objects and stubs for testing in Go?

How can I use tracing tools to understand the execution flow of my Go applications? How can I use tracing tools to understand the execution flow of my Go applications? Mar 10, 2025 pm 05:36 PM

How can I use tracing tools to understand the execution flow of my Go applications?

How can I define custom type constraints for generics in Go? How can I define custom type constraints for generics in Go? Mar 10, 2025 pm 03:20 PM

How can I define custom type constraints for generics in Go?

How to write files in Go language conveniently? How to write files in Go language conveniently? Mar 03, 2025 pm 05:15 PM

How to write files in Go language conveniently?

How to convert MySQL query result List into a custom structure slice in Go language? How to convert MySQL query result List into a custom structure slice in Go language? Mar 03, 2025 pm 05:18 PM

How to convert MySQL query result List into a custom structure slice in Go language?

How do I write benchmarks that accurately reflect real-world performance in Go? How do I write benchmarks that accurately reflect real-world performance in Go? Mar 10, 2025 pm 05:36 PM

How do I write benchmarks that accurately reflect real-world performance in Go?

See all articles