The concept of a keyable model was “inspired” by the Ruby on Rails cache_key system where you cache partials based on the updated timestamp of the instance. This leverages memcached LRU algorithm where unused cache items are not a problem and are discarded after a while of not being used.


To make a model a Keyable Model you need to inherit that class in your model:

from cache_tools.models import KeyableModel
# ...
class Profile(KeyableModel):
  # Your model stuff

Then sync your db or create your south migration:

python schemamigration front add_keyable_model --auto


To use it in your templates you must pass the cache key as a parameter to the cache block:

{% load cache %}
{% cache 86400 cache_tools profile.cache_key %}
        Lots of very time consuming code.
{% endcache %}