Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
Having an optional count in
Redis 3.2 thing, so for now what is needed to go forward is feedbacks, and comparisons with
Example use case
Modeling a web-based game of poker. Populate your deck, and provide 5 cards to every player with
Example call and output
When the set is short on elements (cardinality < count), probably it makes sense to return as much elements as possible. The behavior with non existing keys would be to return an empty array, like
Change of return value
There is the argument about a command changing return value from string to array when an additional argument is given, so actually the following two commands would provide different results:
Both return 1 element, but the second in form of an array. However I think it is straightforward to see the second case as just a special case of the array form, so no confusion should arise. Note: this already happens with
I implemented this feature here, based on the latest 3.0 commit:
As I write this, I realize that [ SPOP key 1 ] runs spopWithCountCommand() while [ SPOP key ] runs spopCommand(). Results should be identical (empty bulk result or bulk result with 1 item), but perhaps I should call the old spopCommand() if COUNT==1.
Please have a look and let me know what you think.