summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy McCurdy <andy@andymccurdy.com>2017-07-31 12:08:45 -0400
committerAndy McCurdy <andy@andymccurdy.com>2017-07-31 12:08:45 -0400
commitfd84f83c64547658371075ddf442edd0f412ea84 (patch)
tree9c42d0e5da3056f72b1b7ba0b8ab7906dbdbd254
parent33fa3750aec259d4c7921a4d5ae7076d45c2ea7b (diff)
parentd4628f383f0c4505175d234cc62189fa459ede2d (diff)
downloadredis-py-fd84f83c64547658371075ddf442edd0f412ea84.tar.gz
Merge branch 'pr/879'
-rwxr-xr-xredis/client.py13
-rw-r--r--tests/test_commands.py5
2 files changed, 15 insertions, 3 deletions
diff --git a/redis/client.py b/redis/client.py
index ec47ac5..9139906 100755
--- a/redis/client.py
+++ b/redis/client.py
@@ -360,9 +360,9 @@ class StrictRedis(object):
bool
),
string_keys_to_dict(
- 'BITCOUNT BITPOS DECRBY DEL GETBIT HDEL HLEN INCRBY LINSERT LLEN '
- 'LPUSHX PFADD PFCOUNT RPUSHX SADD SCARD SDIFFSTORE SETBIT '
- 'SETRANGE SINTERSTORE SREM STRLEN SUNIONSTORE ZADD ZCARD '
+ 'BITCOUNT BITPOS DECRBY DEL GETBIT HDEL HLEN HSTRLEN INCRBY '
+ 'LINSERT LLEN LPUSHX PFADD PFCOUNT RPUSHX SADD SCARD SDIFFSTORE '
+ 'SETBIT SETRANGE SINTERSTORE SREM STRLEN SUNIONSTORE ZADD ZCARD '
'ZLEXCOUNT ZREM ZREMRANGEBYLEX ZREMRANGEBYRANK ZREMRANGEBYSCORE '
'GEOADD',
int
@@ -2017,6 +2017,13 @@ class StrictRedis(object):
"Return the list of values within hash ``name``"
return self.execute_command('HVALS', name)
+ def hstrlen(self, name, key):
+ """
+ Return the number of bytes stored in the value of ``key``
+ within hash ``name``
+ """
+ return self.execute_command('HSTRLEN', name, key)
+
def publish(self, channel, message):
"""
Publish ``message`` on ``channel``.
diff --git a/tests/test_commands.py b/tests/test_commands.py
index 246ef65..465b1dd 100644
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -1229,6 +1229,11 @@ class TestRedisCommands(object):
remote_vals = r.hvals('a')
assert sorted(local_vals) == sorted(remote_vals)
+ def test_hstrlen(self, r):
+ r.hmset('a', {'1': '22', '2': '333'})
+ assert r.hstrlen('a', '1') == 2
+ assert r.hstrlen('a', '2') == 3
+
# SORT
def test_sort_basic(self, r):
r.rpush('a', '3', '2', '1', '4')