Skip to content

Yet another cache backend for django. This one includes: memcache, mintcache and automatic key versioning for gracefull upgrades.

License

Notifications You must be signed in to change notification settings

ella/django-versionedcache

Repository files navigation

Django-versionedcache is a cache backend for Django that:

 - uses MintCache (inspired heavily by http://www.djangosnippets.org/snippets/155/)
 - prepends settings.VERSION to any cache keyto allow gracefull update - you
   can deploy new version of your application without the need for restarting
   your memcached - two versions of the same app can coexist on one memcached
   cluster.
 - to use
     - put versionedcache.backend in settings.CACHE_BACKEND where you
       would normaly use memcached, the rest is the same (IP adresses, ports and
       options to memcached are passed along)
     - maintain a VERSION string in your settings, when you change it,
       versionedcache will use it to identify cache keys belonging to that
       specific version, just change it on update to start using new set of keys
     - see tests/unit_test/settings for example usage

Django-versionedcache also includes a debugging cache backend that wraps
versionedcache backend and adds the following features:

 - ability (for supersusers only!) to turn the cache off per request
 - ability (for supersusers only!) to turn the cache to write-only mode

This is very usefull if you need to debug something on deoployed site and need
to turn the cache off to see the actual results immediately. Once you fix the
problem, you reload the page in write-only mode and the cache will get
overriden with what you saw and want.

To use just add 'versionedcache.middleware.CacheDebugMiddleware' after
'django.contrib.auth.middleware.AuthenticationMiddleware' in your
MIDDLEWARE_CLASSES and use versionedcache.debug:// scheme for your
CACHE_BACKEND with the same options you would use for versionedcache.backend or
memcached. Then when superuser supplies cache_debug=turn_off or
cache_debug=write_only get parameters to any URL it will take effect for that
request only.

Note: CacheDebugMiddleware is not thread safe

About

Yet another cache backend for django. This one includes: memcache, mintcache and automatic key versioning for gracefull upgrades.

Resources

License

Stars

Watchers

Forks

Packages

No packages published