190
190
except Exception, e:
191
191
self._exception_occurred(server, e)
193
def decr(self, key, delta=1, timeout=0):
195
Decrements a key which has a numeric value by delta.
196
If the key can't be found, it's added as 0. Memcached
197
will treat data values below 0 as 0 with incr/decr.
200
:param delta: amount to subtract to the value of key (or set
201
as the value if the key is not found)
202
:param timeout: ttl in memcache
205
for (server, fp, sock) in self._get_conns(key):
207
sock.sendall('decr %s %s\r\n' % (key, delta))
208
line = fp.readline().strip().split()
209
if line[0].upper() == 'NOT_FOUND':
211
sock.sendall('add %s %d %d %s noreply\r\n%s\r\n' %
212
(key, 0, timeout, len(line[0]), line[0]))
213
ret = int(line[0].strip())
214
self._return_conn(server, fp, sock)
217
self._exception_occurred(server, e)
193
219
def delete(self, key):
195
221
Deletes a key/value pair from memcache.