summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy McCurdy <andy@andymccurdy.com>2018-11-06 12:01:39 -0800
committerGitHub <noreply@github.com>2018-11-06 12:01:39 -0800
commitf94147ed2d98560bf04815895215a92c892889f7 (patch)
treee0f123528e70cae482df736dfa43a7f16ae69354
parentd7827d82458944a296166a1e04719920eede1473 (diff)
parent7b7d6c4be51ac12934d5dc47df1bc2d052869898 (diff)
downloadredis-py-f94147ed2d98560bf04815895215a92c892889f7.tar.gz
Merge pull request #933 from yozel/master
Add support for UNLINK command
-rwxr-xr-xredis/client.py4
-rw-r--r--tests/test_commands.py15
2 files changed, 19 insertions, 0 deletions
diff --git a/redis/client.py b/redis/client.py
index f46c7cf..f7b4ca1 100755
--- a/redis/client.py
+++ b/redis/client.py
@@ -1358,6 +1358,10 @@ class StrictRedis(object):
warnings.warn(
DeprecationWarning('Call UNWATCH from a Pipeline object'))
+ def unlink(self, *names):
+ "Unlink one or more keys specified by ``names``"
+ return self.execute_command('UNLINK', *names)
+
# LIST COMMANDS
def blpop(self, keys, timeout=0):
"""
diff --git a/tests/test_commands.py b/tests/test_commands.py
index 1d0e42e..bba29b7 100644
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -303,6 +303,21 @@ class TestRedisCommands(object):
del r['a']
assert r.get('a') is None
+ @skip_if_server_version_lt('4.0.0')
+ def test_unlink(self, r):
+ assert r.unlink('a') == 0
+ r['a'] = 'foo'
+ assert r.unlink('a') == 1
+ assert r.get('a') is None
+
+ @skip_if_server_version_lt('4.0.0')
+ def test_unlink_with_multiple_keys(self, r):
+ r['a'] = 'foo'
+ r['b'] = 'bar'
+ assert r.unlink('a', 'b') == 2
+ assert r.get('a') is None
+ assert r.get('b') is None
+
@skip_if_server_version_lt('2.6.0')
def test_dump_and_restore(self, r):
r['a'] = 'foo'