diff options
author | Yasin Ozel <yasin.ozel@metglobal.com> | 2017-12-01 12:04:17 +0300 |
---|---|---|
committer | Yasin Ozel <yasin.ozel@metglobal.com> | 2017-12-01 12:04:17 +0300 |
commit | 7b7d6c4be51ac12934d5dc47df1bc2d052869898 (patch) | |
tree | 6c0ef41bc3cbf5660ebb3d5264a8dac6c5772748 | |
parent | 5109cb4f6b610e8d5949716a16435afbbf35075a (diff) | |
download | redis-py-7b7d6c4be51ac12934d5dc47df1bc2d052869898.tar.gz |
Add support for UNLINK command
-rwxr-xr-x | redis/client.py | 4 | ||||
-rw-r--r-- | tests/test_commands.py | 15 |
2 files changed, 19 insertions, 0 deletions
diff --git a/redis/client.py b/redis/client.py index 79e94d0..4e8c4cc 100755 --- a/redis/client.py +++ b/redis/client.py @@ -1248,6 +1248,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 b9b9b66..3a189d8 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -285,6 +285,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' |