Commits

Matt Bone committed 2a7ede6

hvals

Comments (0)

Files changed (3)

 
 from commands.keys import delete, rename
 from commands.strings import incr, get, strlen, append, sset, mset, mget, keys
-from commands.hashes import hset, hget, hlen, hdel, hexists, hkeys
+from commands.hashes import hset, hget, hlen, hdel, hexists, hkeys, hvals
 from commands.lists import rpush, rpop, llen
 from commands.sets import sadd, scard, sismember
 from commands.connection import ping, echo
             'hdel': partial(hdel, self.db),
             'hexists': partial(hexists, self.db),
             'hkeys': partial(hkeys, self.db),
+            'hvals': partial(hvals, self.db),
 
             # lists
             'rpush': partial(rpush, self.db),

commands/hashes.py

     """
     # TODO shouldn't need to explictly create a list here...
     return list(db.get(hash_key, {}).keys())
+
+
+def hvals(db, hash_key):
+    """
+    See:
+      - http://redis.io/commands/hvals
+    """
+    # TODO shouldn't need to explictly create a list here...
+    return list(db.get(hash_key, {}).values())

test_integration.py

     assert b"baz" in keys
 
 
+def test_hvals(redis):
+    redis.hset("hash1", "foo", "bar")
+    redis.hset("hash1", "baz", "biz")
+
+    values = redis.hvals("hash1")
+    assert len(values) == 2
+    assert b"bar" in values
+    assert b"biz" in values
+
+
 def test_dbsize(redis):
     redis.set("foo", "bar")
     redis.set("baz", "biz")