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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_clever_cache-0.0.1-py2.py3-none-any.whl.
File metadata
- Download URL: django_clever_cache-0.0.1-py2.py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10ed06759833ac2a188f8d6325fb3f6a2a7b311326f3a6b9e282d344c721ccdf
|
|
| MD5 |
a1a8430fc15b6cc746e5156395182a64
|
|
| BLAKE2b-256 |
bf8c7fc0bc0626b55738dcdbe98a9cf193afbff951527df871540bf67e6b916a
|