Skip to content

fix(set): return scalar for SRANDMEMBER without count - #3601

Open
raghav2005 wants to merge 2 commits into
apache:unstablefrom
raghav2005:fix/srandmember-reply-type
Open

fix(set): return scalar for SRANDMEMBER without count#3601
raghav2005 wants to merge 2 commits into
apache:unstablefrom
raghav2005:fix/srandmember-reply-type

Conversation

@raghav2005

@raghav2005 raghav2005 commented Aug 30, 2026

Copy link
Copy Markdown

Summary

  • return a Redis-compatible bulk string for SRANDMEMBER key
  • return nil for a missing key when count is omitted
  • preserve collection replies for SRANDMEMBER key count
  • add regression coverage for scalar, counted, and missing-key reply types

Closes #2610.

Testing

  • ./x.py build build-docker --unittest --ninja -j 4
  • ./x.py check format
  • ./x.py check tidy build-docker -j 4
  • ./x.py check golangci-lint
  • ./x.py test go build-docker
  • /workspace/build-docker/unittest (623 passed, 1 skipped)
  • /workspace/build-docker/unittest --gtest_filter=RedisSetTest.TakeWithoutPop

Add support for optional count in cmd_set command.
Added tests for SRANDMEMBER function behavior with existing and non-existing keys.
@github-actions

Copy link
Copy Markdown

Hi @raghav2005,

Thank you for your pull request. Please review our Contributing Guide.

Please make sure you understand your changes and explain your reasoning in this pull request. Low-quality pull requests may be closed.

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

Successfully merging this pull request may close these issues.

SRANDMEMBER returns a list from kvrocks when it returns a string on redis

1 participant