A drop-in substitute for the default django.core.cache object. This
implementation is using a modified mint cache approach based on
http://www.djangosnippets.org/snippets/793/.
This implementation does not support specifying fallback values for the
get() function since it would not be possible to otherwise reliably
communicate that the value is stale and has
to be updated.
Configured by three values in settings.py:
- CACHE_DEFAULT_TIMEOUT - how long a set value should be considered valid
(in seconds). After this period the value is considered stale, a single
request starts to update it, and subsequent requests get the old value until
the value gets updated. Default: 300 seconds.
- CACHE_FILELOCK_PATH - path to a non-existant file which will work as an
interprocess lock to make cache access atomic. Default:
/tmp/langacore_django_cache.lock
- CACHE_MINT_DELAY - an upper bound on how long a value should take to be
generated (in seconds). This value is used for stale keys and is the real
time after which the key is completely removed from the cache. Default:
30 seconds.
Functions
-
get(*args, **kwargs)
Get a value from the cache.
| Parameters: | key – the key for which to return the value |
-
set(*args, **kwargs)
Set a value in the cache.
| Parameters: |
- key – the key under which to set the value
- val – the value to set
- timeout – how long should this value be valid, by default
CACHE_DEFAULT_TIMEOUT
- _is_stale – boolean, used internally to set a stale value in the
cache back-end. Don’t use on your own.
|
-
delete(*args, **kwargs)
Removes a value from the cache.
| Parameters: | key – the key to delete from the cache |