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

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 2Python 3

File details

Details for the file django_clever_cache-0.0.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_clever_cache-0.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 10ed06759833ac2a188f8d6325fb3f6a2a7b311326f3a6b9e282d344c721ccdf
MD5 a1a8430fc15b6cc746e5156395182a64
BLAKE2b-256 bf8c7fc0bc0626b55738dcdbe98a9cf193afbff951527df871540bf67e6b916a

See more details on using hashes here.

Supported by

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