Skip to content

sRandMember seems to not support the count argument #2732

@atuttle

Description

@atuttle

Description

I feel like I'm going crazy! How can this not work for such a widely used project?

Redis console, showing that my redis server does the right thing and returns more than 1 row back (yes, the rows are intentionally ~identical, this is test data)

IQ Prod NEW v7:0>SRANDMEMBER "MQ:click-track:LAWR:QA"
"{"ml":"00225535-5c1d-4986-a93b3d7c27e5b427","mc":"0D6DD930-F41E-856C-42796C6D1F84A46F","ts":"2024-04-03T19:05:50.586Z","referer":null}"
IQ Prod NEW v7:0>SRANDMEMBER "MQ:click-track:LAWR:QA" 100
1) "{"ml":"00225535-5c1d-4986-a93b3d7c27e5b427","mc":"0D6DD930-F41E-856C-42796C6D1F84A46F","ts":"2024-04-03T19:14:55.533Z","referer":null}"
2) "{"ml":"00225535-5c1d-4986-a93b3d7c27e5b427","mc":"0D6DD930-F41E-856C-42796C6D1F84A46F","ts":"2024-04-03T19:05:50.586Z","referer":null}"
3) "{"ml":"00225535-5c1d-4986-a93b3d7c27e5b427","mc":"0D6DD930-F41E-856C-42796C6D1F84A46F","ts":"2024-04-03T19:14:52.653Z","referer":null}"
4) "{"ml":"00225535-5c1d-4986-a93b3d7c27e5b427","mc":"0D6DD930-F41E-856C-42796C6D1F84A46F","ts":"2024-04-03T19:01:21.925Z","referer":null}"

But now a node REPL showing that some commands return multiple rows still work as expected (SMEMBERS), but SRANDMEMBER only ever returns 1 row, both with and without the count argument:

node
Welcome to Node.js v18.20.0.
Type ".help" for more information.
> const redis = /* connect to redis server */
undefined
> await redis.SMEMBERS('MQ:click-track:LAWR:QA');
[
  '{"ml":"00225535-5c1d-4986-a93b3d7c27e5b427","mc":"0D6DD930-F41E-856C-42796C6D1F84A46F","ts":"2024-04-03T19:14:55.533Z","referer":null}',
  '{"ml":"00225535-5c1d-4986-a93b3d7c27e5b427","mc":"0D6DD930-F41E-856C-42796C6D1F84A46F","ts":"2024-04-03T19:05:50.586Z","referer":null}',
  '{"ml":"00225535-5c1d-4986-a93b3d7c27e5b427","mc":"0D6DD930-F41E-856C-42796C6D1F84A46F","ts":"2024-04-03T19:14:52.653Z","referer":null}',
  '{"ml":"00225535-5c1d-4986-a93b3d7c27e5b427","mc":"0D6DD930-F41E-856C-42796C6D1F84A46F","ts":"2024-04-03T19:01:21.925Z","referer":null}'
]
> await redis.SRANDMEMBER('MQ:click-track:LAWR:QA');
'{"ml":"00225535-5c1d-4986-a93b3d7c27e5b427","mc":"0D6DD930-F41E-856C-42796C6D1F84A46F","ts":"2024-04-03T19:14:52.653Z","referer":null}'
> await redis.SRANDMEMBER('MQ:click-track:LAWR:QA', 100);
'{"ml":"00225535-5c1d-4986-a93b3d7c27e5b427","mc":"0D6DD930-F41E-856C-42796C6D1F84A46F","ts":"2024-04-03T19:01:21.925Z","referer":null}'
>

Node.js Version

18.20.0

Redis Server Version

7.0.7

Node Redis Version

1.5.14

Platform

MacOS, Linux (AWS Lambda)

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions