summaryrefslogtreecommitdiff
path: root/redis/client.py
diff options
context:
space:
mode:
authorAndy McCurdy <andy@andymccurdy.com>2010-04-19 16:09:04 -0700
committerAndy McCurdy <andy@andymccurdy.com>2010-04-19 16:09:04 -0700
commit7aef2c8202746b5966526dcfdd9f531dcf9096d8 (patch)
tree0e16eda0697ae1acf965795f714e99f9e2c0b72e /redis/client.py
parent18f2a0253e7a9b87d84d2f7767b2d7f85f39f11f (diff)
downloadredis-py-7aef2c8202746b5966526dcfdd9f531dcf9096d8.tar.gz
added support for APPEND and SUBSTR commands
Diffstat (limited to 'redis/client.py')
-rw-r--r--redis/client.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/redis/client.py b/redis/client.py
index ab0e9f2..05fc4b8 100644
--- a/redis/client.py
+++ b/redis/client.py
@@ -481,6 +481,14 @@ class Redis(threading.local):
return self.execute_command('SAVE')
#### BASIC KEY COMMANDS ####
+ def append(self, key, value):
+ """
+ Appends the string ``value`` to the value at ``key``. If ``key``
+ doesn't already exist, create it with a value of ``value``.
+ Returns the new length of the value at ``key``.
+ """
+ return self.execute_command('APPEND', key, value)
+
def decr(self, name, amount=1):
"""
Decrements the value of ``key`` by ``amount``. If no key exists,
@@ -606,6 +614,13 @@ class Redis(threading.local):
"Set the value of key ``name`` to ``value`` if key doesn't exist"
return self.execute_command('SETNX', name, value)
+ def substr(self, name, start, end=-1):
+ """
+ Return a substring of the string at key ``name``. ``start`` and ``end``
+ are 0-based integers specifying the portion of the string to return.
+ """
+ return self.execute_command('SUBSTR', name, start, end)
+
def ttl(self, name):
"Returns the number of seconds until the key ``name`` will expire"
return self.execute_command('TTL', name)