djblets.cache.forwarding_backend¶
A cache backend that forwards to other dynamically-configured backends.
- class ForwardingCacheBackend(cache_name='forwarded_backend', *args, **kwargs)[source]¶
Bases:
object
Forwards requests to another cache backend.
This is used to allow for dynamic configuration of caches that can be swapped in and out. By setting this cache backend as the default backend, the consumer can easily switch between other cache backends without modifying
settings.py
and restarting the app.This by default looks for another cache backend in
settings.CACHES['forwarded_backend']
. This can be changed with theLOCATION
setting for this cache backend. All requests and attribute lookups will be forwarded there.If a consumer switches the real cache backend, it can call
reset_backend()
, and all future cache requests will go to the newly computed backend.