Permalink
Browse files

SRANDMEMBER <count> doc update.

  • Loading branch information...
1 parent 7d81c58 commit f13fbe3f375685cbf595935d6d8b6f9f976313e1 @antirez committed Sep 23, 2012
Showing with 8 additions and 3 deletions.
  1. +7 −2 commands.json
  2. +1 −1 commands/srandmember.md
View
@@ -1656,12 +1656,17 @@
"group": "set"
},
"SRANDMEMBER": {
- "summary": "Get a random member from a set",
- "complexity": "O(1)",
+ "summary": "Get one or multiple random members from a set",
+ "complexity": "Without the count argument O(1), otherwise O(N) where N is the absolute value of the passed count.",
"arguments": [
{
"name": "key",
"type": "key"
+ },
+ {
+ "name": "count",
+ "type": "integer",
+ "optional": true
}
],
"since": "1.0.0",
View
@@ -1,6 +1,6 @@
When called with just the `key` argument, return a random element from the set value stored at `key`.
-When called with the additional `count` argument, return an array of `count` **distinct elements** if `count` is positive. If called with a negative `count` the behavior changes and the command is allowed to return the **same element multiple times**. In this case the numer of returned elements is the absolute value of the specified `count`.
+Starting from Redis version 2.6, when called with the additional `count` argument, return an array of `count` **distinct elements** if `count` is positive. If called with a negative `count` the behavior changes and the command is allowed to return the **same element multiple times**. In this case the numer of returned elements is the absolute value of the specified `count`.
When called with just the key argument, the operation is similar to `SPOP`, however while `SPOP` also removes the randomly selected element from the set, `SRANDMEMBER` will just return a random element without altering the original set in any way.

0 comments on commit f13fbe3

Please sign in to comment.