Permalink
Browse files

add __setitem__, __getitem__ and __delitem__

  • Loading branch information...
salimane committed Sep 15, 2012
1 parent 1598d93 commit 619c13329fd3d0bb80df103226e09316bbdb7c59
Showing with 179 additions and 162 deletions.
  1. +0 −1 rediscluster/__init__.py
  2. +18 −0 rediscluster/client.py
  3. +161 −161 tests/server_commands.py
View
@@ -9,7 +9,6 @@
ResponseError,
WatchError,
)
-from redis.client import parse_info
__version__ = '0.2.3'
VERSION = tuple(map(int, __version__.split('.')))
View
@@ -166,6 +166,24 @@ def function(*args, **kwargs):
return function
+ def __setitem__(self, name, value):
+ "Set the value at key ``name`` to ``value``"
+ return self.set(name, value)
+
+ def __getitem__(self, name):
+ """
+ Return the value at key ``name``, raises a KeyError if the key
+ doesn't exist.
+ """
+ value = self.get(name)
+ if value:
+ return value
+ raise KeyError(name)
+
+ def __delitem__(self, *names):
+ "Delete one or more keys specified by ``names``"
+ return self.delete(*names)
+
def object (self, infotype, key):
"Return the encoding, idletime, or refcount about the key"
redisent = self.redises[self.cluster['master_of']['node_' + str((abs(binascii.crc32(b(key)) & 0xffffffff) % self.no_servers) + 1)]]
Oops, something went wrong.

0 comments on commit 619c133

Please sign in to comment.