Commits

Matt Bone committed dace870

mget

Comments (0)

Files changed (4)

 from functools import partial
 
 from commands.keys import delete
-from commands.strings import incr, get, strlen, append, sset
+from commands.strings import incr, get, strlen, append, sset, mset, mget
 from commands.hashes import hset, hget, hlen
 from commands.lists import rpush, rpop, llen
 from commands.sets import sadd, scard, sismember
             'decrby': partial(incr, self.db, mult=-1),
             'set': partial(sset, self.db),
             'get': partial(get, self.db),
+            'mset': partial(mset, self.db),
+            'mget': partial(mget, self.db),
             'strlen': partial(strlen, self.db),
             'append': partial(append, self.db),
 
     db[key] = value
 
 
+def mget(db, *requested_keys):
+    return [db.get(requested_key) for requested_key in requested_keys]
+
+
+def mset(db, keys_and_values):
+    pass
+
+
 def incr(db, key, *args, mult=1):
     """
     See:
         """
         self.sendLine(b"*" + str(len(values)).encode())
         for value in values:
-            for response in self.responseForValue(value):
+            for response in self._responsesForValue(value):
                 self.sendLine(response)
 
 
             raise Exception("Unknown response: " + result)
 
 
-
 class RedisInPyFactory(protocol.Factory):
     backend = Backend()
 
     assert b'1' == redis.get("hello")
 
 
+def test_mset(redis):
+    pass
+
+
+def test_mget(redis):
+    redis.set('foo', 'bar')
+    redis.set('biz', 'baz')
+
+    assert b"bar" == redis.get("foo")
+    assert b"baz" == redis.get("biz")
+
+    bar, baz = redis.mget(["foo", "biz"])
+    assert bar == b"bar"
+    assert baz == b"baz"
+
+
 def test_incr(redis):
     redis.set("counter", 1)
     counter = redis.incr("counter")  # boo, always uses incrby