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:

    '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 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.

class johnny.backends.locmem.LocMemCache(name, params)


Infinite file-based caching. Caches forever when passed timeout of 0.

class johnny.backends.filebased.FileBasedCache(dir, params)


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.

class johnny.backends.redis.RedisCache(server, params)