Johnny provides a number of backends, all of which are subclassed versions of django builtins that cache “forever” when passed a 0 timeout. These are essentially the same as mmalone’s inspiring django-caching application’s cache backend monkey-patch.
The way Django interprets cache backend URIs has changed during its history. Please consult the specific cache documentation for your version of Django for the exact usage you should use.
Example usage for various Django versions:
CACHE_BACKEND="johnny.backends.memcached//..." # django <= 1.2
CACHE_BACKEND="johnny.backends.memcached.MemcachedCache//..." # django > 1.2
CACHES = {
'default' : {
'BACKEND': 'johnny.backends.memcached.PyLibMCCache',
'LOCATION': '...',
}
}
Important Note: The locmem and filebased caches are NOT recommended for setups in which there is more than one server using Johnny; invalidation will break with potentially disasterous results if the cache Johnny uses is not shared amongst all machines writing to the database.
Infinite caching memcached class. Caches forever when passed a timeout of 0. For Django >= 1.3, this module also provides MemcachedCache and PyLibMCCache, which use the backends of their respective analogs in django’s default backend modules.
Infinitely Caching version of django’s MemcachedCache backend.
PyLibMCCache version that interprets 0 to mean, roughly, 30 days. This is because pylibmc interprets 0 to mean literally zero seconds rather than “infinity” as memcached itself does. The maximum timeout memcached allows before treating the timeout as a timestamp is just under 30 days.
Infinite caching locmem class. Caches forever when passed timeout of 0.
This actually doesn’t cache “forever”, just for a very long time. On 32 bit systems, it will cache for 68 years, quite a bit longer than any computer will last. On a 64 bit machine, your cache will expire about 285 billion years after the Sun goes red-giant and destroys Earth.
Locmem cache interpreting 0 as “a very long time”, named according to the Django 1.3 conventions.
Infinite file-based caching. Caches forever when passed timeout of 0.
File based cache named according to Django >= 1.3 conventions.
Redis cache classes that forcebly limits the timeout of the redis cache backend to 30 days to make sure the cache doesn’t fill up when johnny always caches queries. Redis doesn’t have an automatic cache invalidation other than timeouts.
This module depends on the django-redis-cache app from PyPI.