django-utils v0.3.0 documentation
Decorator for creating a cached template filter.
@register.filter @cached_filter def expensive_filter(value): ... do something expensive
Base class for creating cached template Nodes. This class is designed to not dogpile in the event a cache key expires. Suppose the data takes 3 seconds to calculate and you get 100 requests/s, that’s ~300 hits. This class provides several ways to avoid this problem, either by blocking until the cache has been repopulated or by return an empty result.
To avoid dogpiling the time the cached data expires is stored along with the cached data and if it is nearing expiration, a single call is made that will repopulate the data (hopefully before it expires).
There are a number of ways you can configure the operation of this class:
The default time to store data in the cache
Whether or not to block when cache is populating
Whether to wait on repopulating call or fire off another call to the get_content method
If using a spin-lock, initial time to sleep, rate of backoff, maximum
return a unique cache key based on the available context
return any content – what you would normally return in render()