summaryrefslogtreecommitdiff
path: root/redis/client.py
diff options
context:
space:
mode:
authorsebleier <sebleier@gmail.com>2010-05-30 04:56:19 +0800
committerAndy McCurdy <andy@andymccurdy.com>2010-06-02 01:41:59 +0800
commit9f0ed62fbc1e648207478c24342512acb3ea01aa (patch)
tree86de73c0478f38fa581c98f8fbf86784b4ac2aed /redis/client.py
parentdd8421273d4b17adfda56e8b753bdf92d4d43fb5 (diff)
downloadredis-py-9f0ed62fbc1e648207478c24342512acb3ea01aa.tar.gz
Added HSETNX command and tests
Diffstat (limited to 'redis/client.py')
-rw-r--r--redis/client.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/redis/client.py b/redis/client.py
index eb58657..9f17ae7 100644
--- a/redis/client.py
+++ b/redis/client.py
@@ -1089,6 +1089,13 @@ class Redis(threading.local):
"""
return self.execute_command('HSET', name, key, value)
+ def hsetnx(self, name, key, value):
+ """
+ Set ``key`` to ``value`` within hash ``name`` if ``key`` does not
+ exist. Returns 1 if HSETNX created a field, otherwise 0.
+ """
+ return self.execute_command("HSETNX", name, key, value)
+
def hmset(self, name, mapping):
"""
Sets each key in the ``mapping`` dict to its corresponding value