Skip to content
Cache dispatcher.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Cachecontrol allows to manage cached values and easily link them to Model signals



import cachecontrol
cachecontrol.autodiscover() file

Method to attach cache to the model is to define keypairs. Each defined keypair creates model's save and delete signal. func takes chenged model and returns number of changed vary_on arg and value of this arg. When the signal is called, it gets varied arg and deletes all caches with this arg.

from cachecontrol import registry
from models import MyModel

caches = [
    #(cache_name, number of vary_on args, [(model, func) keypairs])
    ('cache_of_0_args', 0, [(MyModel, lambda obj: None )]),
    ('cache_of_2_args', 2, [(MyModel, lambda obj: (0, )]),



{% load controlledcache %}
{% controlledcache 600 cache_of_2_args page_number %}
{# controlledcache expire_timeout cache_name [vary_on args|...] #}
{% endcontrolledcache %}
You can’t perform that action at this time.