Commit dd84fe45 authored by Jannis Leidel's avatar Jannis Leidel Committed by Sean Bleier

More cosmetic changes, yay.

parent c6aab1bc
...@@ -17,7 +17,9 @@ except: ...@@ -17,7 +17,9 @@ except:
class CacheClass(BaseCache): class CacheClass(BaseCache):
def __init__(self, server, params): def __init__(self, server, params):
"Connect to Redis, and set up cache backend." """
Connect to Redis, and set up cache backend.
"""
BaseCache.__init__(self, params) BaseCache.__init__(self, params)
self._cache = redis.Redis(server.split(':')[0], db=1) self._cache = redis.Redis(server.split(':')[0], db=1)
...@@ -62,19 +64,27 @@ class CacheClass(BaseCache): ...@@ -62,19 +64,27 @@ class CacheClass(BaseCache):
def expire(self, key, timeout=None): def expire(self, key, timeout=None):
""" """
set content expiration, if necessary Set content expiration, if necessary
""" """
timeout = timeout or self.default_timeout timeout = timeout or self.default_timeout
self._cache.expire(smart_str(key), timeout) self._cache.expire(smart_str(key), timeout)
def delete(self, key): def delete(self, key):
"Remove a key from the cache." """
Remove a key from the cache.
"""
self._cache.delete(smart_str(key)) self._cache.delete(smart_str(key))
def delete_many(self, keys): def delete_many(self, keys):
"""
Remove multiple keys at once.
"""
self._cache.delete(*map(smart_str, keys)) self._cache.delete(*map(smart_str, keys))
def clear(self): def clear(self):
"""
Flush all cache keys.
"""
self._cache.flushdb() self._cache.flushdb()
def get_many(self, keys): def get_many(self, keys):
...@@ -98,8 +108,7 @@ class CacheClass(BaseCache): ...@@ -98,8 +108,7 @@ class CacheClass(BaseCache):
def set_many(self, data, timeout=None): def set_many(self, data, timeout=None):
""" """
Set a bunch of values in the cache at once from a dict of key/value Set a bunch of values in the cache at once from a dict of key/value
pairs. For certain backends (memcached), this is much more efficient pairs. This is much more efficient than calling set() multiple times.
than calling set() multiple times.
If timeout is given, that timeout will be used for the key; otherwise If timeout is given, that timeout will be used for the key; otherwise
the default cache timeout will be used. the default cache timeout will be used.
......
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