Commit 2867c78f authored by Tomi Suomela's avatar Tomi Suomela

Cache: getset() and incrby() added

parent 74b834c6
......@@ -546,3 +546,19 @@ class BaseRedisCache(BaseCache):
def has_fresh_key(self, client, key):
"""Returns True if the fresh key is in the cache and has not expired."""
return client.exists("__fresh__" + key)
@get_client(write=True)
def getset(self, client, key, value):
"""
Sets the value at key ``name`` to ``value``
and returns the old value at key ``name`` atomically.
"""
return client.getset(key, value)
@get_client(write=True)
def incrby(self, client, key, amount=1):
"""
Increments the value of ``key`` by ``amount``. If no key exists,
the value will be initialized as ``amount``
"""
return client.incrby(key, amount=1)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment