{"action":"created","issue":{"url":"https://api.github.com/repos/andymccurdy/redis-py/issues/593","labels_url":"https://api.github.com/repos/andymccurdy/redis-py/issues/593/labels{/name}","comments_url":"https://api.github.com/repos/andymccurdy/redis-py/issues/593/comments","events_url":"https://api.github.com/repos/andymccurdy/redis-py/issues/593/events","html_url":"https://github.com/andymccurdy/redis-py/issues/593","id":59380612,"number":593,"title":"SPOP Count?","user":{"login":"seaux","id":1952445,"avatar_url":"https://avatars.githubusercontent.com/u/1952445?v=3","gravatar_id":"","url":"https://api.github.com/users/seaux","html_url":"https://github.com/seaux","followers_url":"https://api.github.com/users/seaux/followers","following_url":"https://api.github.com/users/seaux/following{/other_user}","gists_url":"https://api.github.com/users/seaux/gists{/gist_id}","starred_url":"https://api.github.com/users/seaux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seaux/subscriptions","organizations_url":"https://api.github.com/users/seaux/orgs","repos_url":"https://api.github.com/users/seaux/repos","events_url":"https://api.github.com/users/seaux/events{/privacy}","received_events_url":"https://api.github.com/users/seaux/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-03-01T05:07:09Z","updated_at":"2015-03-10T09:23:55Z","closed_at":null,"body":"Hey andy/community,\r\n\r\nRedis supports a count field when calling SPOP (http://redis.io/commands/spop), but I don't think this framework has support for that.\r\n\r\nNot sure if this was intentional (for some odd reason of which I'm unaware) or not, but it'd be useful to have.\r\n\r\nI copy and pasted my patch below if you want to use it. I basically just duplicated the code for srandmember since even Redis docs mention they work the same. Although, it would've been nice to have the arg be `count` and not `number`.\r\n\r\n```diff\r\ndiff --git a/redis/client.py b/redis/client.py\r\nindex 8b5a3fa..0f5ad93 100755\r\n--- a/redis/client.py\r\n+++ b/redis/client.py\r\n@@ -1532,9 +1532,17 @@ class StrictRedis(object):\r\n         \"Move ``value`` from set ``src`` to set ``dst`` atomically\"\r\n         return self.execute_command('SMOVE', src, dst, value)\r\n\r\n-    def spop(self, name):\r\n-        \"Remove and return a random member of set ``name``\"\r\n-        return self.execute_command('SPOP', name)\r\n+    def spop(self, name, number=None):\r\n+        \"\"\"\r\n+        Remove and return a random member of set ``name``\"\r\n+\r\n+        If ``number`` is None, pops a random member of set ``name``.\r\n+\r\n+        If ``number`` is supplied, pops a list of ``number`` random\r\n+        members of set ``name``.\r\n+        \"\"\"\r\n+        args = number and [number] or []\r\n+        return self.execute_command('SPOP', name, *args)\r\n\r\n     def srandmember(self, name, number=None):\r\n         \"\"\"\r\ndiff --git a/tests/test_commands.py b/tests/test_commands.py\r\nindex 286ea04..5c43feb 100644\r\n--- a/tests/test_commands.py\r\n+++ b/tests/test_commands.py\r\n@@ -844,6 +844,13 @@ class TestRedisCommands(object):\r\n         assert value in s\r\n         assert r.smembers('a') == set(s) - set([value])\r\n\r\n+    def test_spop_multi_value(self, r):\r\n+        s = [b('1'), b('2'), b('3')]\r\n+        r.sadd('a', *s)\r\n+        values = r.spop('a', 2)\r\n+        assert values in s\r\n+        assert r.smembers('a') == set(values) < set(s)\r\n+\r\n     def test_srandmember(self, r):\r\n         s = [b('1'), b('2'), b('3')]\r\n         r.sadd('a', *s)\r\n```\r\n\r\n[Edited: Added patch to tests in `test_commands.py`]\r\nRyan"},"comment":{"url":"https://api.github.com/repos/andymccurdy/redis-py/issues/comments/78019634","html_url":"https://github.com/andymccurdy/redis-py/issues/593#issuecomment-78019634","issue_url":"https://api.github.com/repos/andymccurdy/redis-py/issues/593","id":78019634,"user":{"login":"argvk","id":936609,"avatar_url":"https://avatars.githubusercontent.com/u/936609?v=3","gravatar_id":"","url":"https://api.github.com/users/argvk","html_url":"https://github.com/argvk","followers_url":"https://api.github.com/users/argvk/followers","following_url":"https://api.github.com/users/argvk/following{/other_user}","gists_url":"https://api.github.com/users/argvk/gists{/gist_id}","starred_url":"https://api.github.com/users/argvk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/argvk/subscriptions","organizations_url":"https://api.github.com/users/argvk/orgs","repos_url":"https://api.github.com/users/argvk/repos","events_url":"https://api.github.com/users/argvk/events{/privacy}","received_events_url":"https://api.github.com/users/argvk/received_events","type":"User","site_admin":false},"created_at":"2015-03-10T09:23:55Z","updated_at":"2015-03-10T09:23:55Z","body":"from the [spop command doc](http://redis.io/commands/spop)\r\n> The count arugment will be available in 3.0 and is not available in 2.6 or 2.8"}}