-
Notifications
You must be signed in to change notification settings - Fork 5
/
README
36 lines (30 loc) · 1.86 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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