Skip to content

Xrange - impossible to provide count argument #3081

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
fliespl opened this issue Aug 6, 2024 · 6 comments
Open

Xrange - impossible to provide count argument #3081

fliespl opened this issue Aug 6, 2024 · 6 comments

Comments

@fliespl
Copy link

fliespl commented Aug 6, 2024

		messages, err := t.client.XRange(ctx, t.streamName, fromSeq, "+ COUNT 1").Result()

Possibility to provide "+ count 1" as stop argument or stop as "+" and option count 1

Current Behavior

ERR Invalid stream ID specified as stream command argument

Also, it's impossible to execute as described in xrange documention:

XRANGE writers (1526985685298-0 + COUNT 2

@ndyakov
Copy link
Member

ndyakov commented Apr 14, 2025

Hello @fliespl thank you for reporting this. Do you recall which version of redis and go-redis were you using when you failed to execute the said command?

@fliespl
Copy link
Author

fliespl commented Apr 15, 2025

@ndyakov according to go.mod it was. Can't remember redis version though.

github.com/redis/go-redis/v9 v9.6.1 h1:HHDteefn6ZkTtY5fGUE8tj8uy85AHk6zP7CpzIAM0y4=
github.com/redis/go-redis/v9 v9.6.1/go.mod h1:0C0c6ycQsdpVNQpxb1njEQIqkx5UcsM8FJCQLgE9+RA=

@ndyakov
Copy link
Member

ndyakov commented Apr 15, 2025

@andy-stark-redis can we add doctests with the said usage for xrange if we don't have already and verify it they do work with the current version?

@andy-stark-redis
Copy link
Contributor

@fliespl @ndyakov I might be misunderstanding the issue here, but aren't you supposed to use the XRangeN() variant when you want to supply a count? This is actually what is shown in the Go example in the streams datatype page.

@fliespl
Copy link
Author

fliespl commented Apr 16, 2025

If I remember correctly, it was this case: @andy-stark-redis

> XRANGE race:france (1692632094485-0 + COUNT 2
1) 1) "1692632102976-0"
   2) 1) "rider"
      2) "Prickett"
      3) "speed"
      4) "29.7"
      5) "position"
      6) "2"
      7) "location_id"
      8) "1"
2) 1) "1692632147973-0"
   2) 1) "rider"
      2) "Castilla"
      3) "speed"
      4) "29.9"
      5) "position"
      6) "1"
      7) "location_id"
      8) "2"

@andy-stark-redis
Copy link
Contributor

@fliespl Found it - the Go tab for that example has this code, using XRangeN() instead of XRange():

res15, err := rdb.XRangeN(ctx, "race:france",
	"(1692632094485-0", "+", 2,
).Result()

if err != nil {
	panic(err)
}

fmt.Println(res15)

It's a testable example and the tests pass, so presumably the code is OK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants