diff options
| author | Sean Reifschneider <jafo@tummy.com> | 2008-04-29 21:19:23 -0600 |
|---|---|---|
| committer | Sean Reifschneider <jafo@tummy.com> | 2008-04-29 21:19:23 -0600 |
| commit | 2c92db26e8ae5e4c98fa5f22fb340ec083c1ee5b (patch) | |
| tree | 2303c6462bde752e148157c9b816451bb11b40e0 | |
| parent | 5ba930639500cfac5c895238469f27e29717c06e (diff) | |
| download | python-memcached-2c92db26e8ae5e4c98fa5f22fb340ec083c1ee5b.tar.gz | |
Patch from Andrey Petrov to add the "append" and "replace" commands.
| -rw-r--r-- | ChangeLog | 2 | ||||
| -rw-r--r-- | memcache.py | 22 |
2 files changed, 24 insertions, 0 deletions
@@ -5,6 +5,8 @@ Tue, 29 Apr 2008 21:03:53 -0600 Sean Reifschneider <jafo@tummy.com> * Patch from Jehiah Czebotar to catch an additional server disconnect situation. + * Patch from Andrey Petrov to add the "append" and "replace" commands. + Tue, 18 Sep 2007 20:52:09 -0600 Sean Reifschneider <jafo@tummy.com> * Version 1.40 diff --git a/memcache.py b/memcache.py index 2db6c5b..b9f5633 100644 --- a/memcache.py +++ b/memcache.py @@ -397,6 +397,27 @@ class Client(local): ''' return self._set("add", key, val, time, min_compress_len) + def append(self, key, val, time=0, min_compress_len=0): + '''Append the value to the end of the existing key's value. + + Only stores in memcache if key already exists. + Also see L{prepend}. + + @return: Nonzero on success. + @rtype: int + ''' + return self._set("append", key, val, time, min_compress_len) + + def prepend(self, key, val, time=0, min_compress_len=0): + '''Prepend the value to the beginning of the existing key's value. + + Only stores in memcache if key already exists. + Also see L{append}. + + @return: Nonzero on success. + @rtype: int + ''' + return self._set("prepend", key, val, time, min_compress_len) def replace(self, key, val, time=0, min_compress_len=0): '''Replace existing key with value. @@ -408,6 +429,7 @@ class Client(local): @rtype: int ''' return self._set("replace", key, val, time, min_compress_len) + def set(self, key, val, time=0, min_compress_len=0): '''Unconditionally sets a key to a given value in the memcache. |
