Skip to main content

Django cache backend with automatic granular invalidation

Project description

Django cache backend with automatic granular invalidation.

Requires

  • django >= 1.8

  • redis >= 3.0

  • django-redis

Installation and setup

$ pip install django-clever-cache

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

CACHES = {
    "default": {
        "BACKEND": 'clever_cache.backend.RedisCache',
        "LOCATION": "redis://127.0.0.1:6379/1",
        "OPTIONS": {
            'DB': 1,
        }
    }
}

Usage

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