Skip to main content

Django cache backend with automatic granular invalidation

Project description

Django cache backend with automatic granular invalidation.


  • django >= 1.8

  • redis >= 3.0

  • django-redis

Installation and setup

$ pip install django-clever-cache

in add clever_cache to INSTALLED_APPS, and set clever_cache.backend.RedisCache as your cache backend.

    "default": {
        "BACKEND": 'clever_cache.backend.RedisCache',
        "LOCATION": "redis://",
        "OPTIONS": {
            'DB': 1,


to save value in cache use standart function django.core.cache.cache.set with optional argument depends_on: cache.set(key, value, depends_on=[<dependencies_list>])

Dependency can be:

Model class

if you set model class as dependency (cache.set(key, value, depends_on=[SomeModel])), and change any instance of SomeModel, call bulk_create, update or delete to model’s queryset, key will be invalidated.

Model instance

if you set model instance as dependency (cache.set(key, value, depends_on=[some_instance])), and change this instance(including changing m2m fields), key will be invalidated.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

django_clever_cache-0.0.1-py2.py3-none-any.whl (11.5 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page