You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kvrocks.apache.org by "Rafiot (via GitHub)" <gi...@apache.org> on 2024/10/18 19:14:45 UTC
[I] SRANDMEMBER returns a list from kvrocks when it returns a string on redis [kvrocks]
Rafiot opened a new issue, #2610:
URL: https://github.com/apache/kvrocks/issues/2610
### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/kvrocks/issues) and found no similar issues.
### Version
Ubuntu 24.04 / kvrocks 2.10 / valkey 8.0
### Minimal reproduce step
```python
from redis import Redis
r.sadd('foo', 'bar')
r.srandmember('foo')
# returns [b'bar'] from kvrocks, b'bar' from valkey
```
### What did you expect to see?
The same output against both backends.
### What did you see instead?
`[b'bar']` from kvrocks, `b'bar'` from valkey
### Anything Else?
I cannot say who's wrong, it's just super confusing to have two different responses.
The solution I'll go for to have a consistent output is to pass `r.srandmember('foo', 1)` which returns a list against both backends.
### Are you willing to submit a PR?
- [ ] I'm willing to submit a PR!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] SRANDMEMBER returns a list from kvrocks when it returns a string on redis [kvrocks]
Posted by "git-hulk (via GitHub)" <gi...@apache.org>.
git-hulk closed issue #2610: SRANDMEMBER returns a list from kvrocks when it returns a string on redis
URL: https://github.com/apache/kvrocks/issues/2610
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] SRANDMEMBER returns a list from kvrocks when it returns a string on redis [kvrocks]
Posted by "git-hulk (via GitHub)" <gi...@apache.org>.
git-hulk commented on issue #2610:
URL: https://github.com/apache/kvrocks/issues/2610#issuecomment-2424462116
@Rafiot Good point. It'd be better to document explicitly instead of silently breaking old behaviors in some programming languages. And always return the array format makes sense whether the count is bigger than 1 or not.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] SRANDMEMBER returns a list from kvrocks when it returns a string on redis [kvrocks]
Posted by "git-hulk (via GitHub)" <gi...@apache.org>.
git-hulk commented on issue #2610:
URL: https://github.com/apache/kvrocks/issues/2610#issuecomment-2423422149
@Rafiot Thanks for your report. Redis did have a different reply behavior when count is 1.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] SRANDMEMBER returns a list from kvrocks when it returns a string on redis [kvrocks]
Posted by "Rafiot (via GitHub)" <gi...@apache.org>.
Rafiot commented on issue #2610:
URL: https://github.com/apache/kvrocks/issues/2610#issuecomment-2423788447
yep. I don't know if it is something to change or not, I don't see a good solution to that, as you will either break existing kvrocks-only tools in a very weird way, or keep the difference.
It would probably make sense to document the difference somewhere so people don't spend hours debugging it, and make sure to always pass the count parameter.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] SRANDMEMBER returns a list from kvrocks when it returns a string on redis [kvrocks]
Posted by "Rafiot (via GitHub)" <gi...@apache.org>.
Rafiot commented on issue #2610:
URL: https://github.com/apache/kvrocks/issues/2610#issuecomment-2423983226
That's an option, but it will break existing codebases:
```python
from redis import Redis
r.sadd('foo', 'bar')
if member := r.srandmember('foo'):
print(member[0])
# do something with member[0]
```
That call was getting the one element from the list and will now get the first char of the response, and it won't even fail.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] SRANDMEMBER returns a list from kvrocks when it returns a string on redis [kvrocks]
Posted by "git-hulk (via GitHub)" <gi...@apache.org>.
git-hulk commented on issue #2610:
URL: https://github.com/apache/kvrocks/issues/2610#issuecomment-2423967976
Yes, we can fix it to align with Redis.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] SRANDMEMBER returns a list from kvrocks when it returns a string on redis [kvrocks]
Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on issue #2610:
URL: https://github.com/apache/kvrocks/issues/2610#issuecomment-2423789303
I'm ok with changing this to same as redis 🤔
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org