Get a value from the cache or call ``func`` to set it and return it.
Retrieves a key value from the cache and sets the value if it does not exist.
This implementation is slightly more advanced that Django's. It provides thundering herd
protection, which prevents multiple threads/processes from calling the value-generating
function too much.
:param key: Location of the value
:param func: Callable used to set the value if key does not exist.
:param timeout: Number of seconds to hold value in cache.
:param timeout: Time in seconds that value at key is considered fresh.
:type timeout: Number of seconds or None
:param lock_timeout: Time in seconds that the lock will stay active and prevent other threads from acquiring the lock.
:type lock_timeout: Number of seconds or None
:param stale_cache_timeout: Time in seconds that the stale cache will remain after the key has expired. If ``None`` is specified, the stale value will remain indefinitely.
:type stale_cache_timeout: Number of seconds or None
.. function:: reinsert_keys(self):
...
...
@@ -147,12 +162,9 @@ Cache Methods Provided by django-redis-cache
`django-redis-cache`_ is a cache backend for the `Django`_ webframework. It
`django-redis-cache`_ is a cache backend for the `Django`_ webframework. It
uses the `redis`_ server, which is a in-memory key-value data structure server.
Similar to the great `Memcached`_ in performance, it has several features that
makes it more appealing.
...
...
@@ -24,7 +24,7 @@ makes it more appealing.
* Many more.
Many of these features are irrelevant to caching, but can be used by other
areas of a web stack and therefore offer a compelling case to simplify your
areas of a web stack and therefore offers a compelling case to simplify your
infrastructure.
...
...
@@ -35,7 +35,7 @@ Quick Start
**Recommended:**
* `redis`_ >= 2.4
* `redis`_ >= 2.8
* `redis-py`_ >= 2.10.3
...
...
@@ -59,7 +59,7 @@ of redis. Start the server by running ``./src/redis-server``
}
**Warning: By default, django-redis-cache set keys in the database 1 of Redis. By default, a session with redis-cli start on database 0. Switch to database 1 with** ``SELECT 1``.