django-update-cache
Lazy cache updates for Django.
Rationale
Cache function results with optional asynchronous updates.
Support
Supports: Python 3.10.
Supports Django Versions: 4.2.7
Installation
$ pip install django-update-cache
Usage
Add update_cache.apps.UpdateCacheConfig to INSTALLED_APPS.
Run migrations:
python manage.py migrate
Add a module cached_functions to one or more of your apps. Decorate any function for which you want the results to be
cached:
# cached_functions.py
from update_cache.decorators import cache_function
@cache_function()
def my_expensive_function():
...
Specify a specific timeout:
# cached_functions.py
from update_cache.decorators import cache_function
@cache_function(timeout=60)
def my_expensive_function():
...
Use asynchronous updating (this requires running a django_rq worker):
# cached_functions.py
from update_cache.brokers import async_broker
from update_cache.decorators import cache_function
@cache_function(broker=async_broker)
def my_expensive_function():
...
Use a custom cache backend:
# cached_functions.py
from update_cache.decorators import cache_function
@cache_function(backend='my_cache_alias')
def my_expensive_function():
...
You can set a global broker to delegate the cache updates in settings.py.
DUC_DEFAULT_BROKER = 'update_cache.brokers.AsyncBroker'
Invalidate the cache:
# cached_functions.py
from update_cache.decorators import cache_function
@cache_function()
def my_expensive_function():
...
my_expensive_function.cache.invalidate()
Cache a view (only synchronous updates).
# cached_functions.py
from update_cache.decorators import cache_view
@cache_view()
def my_expensive_view():
...
View all cached entries in Django Admin:
Metadata
Release files for django-update-cache 1.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| django-update-cache-1.0.6.tar.gz | 116.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_update_cache-1.0.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 127.4 kB
Release files / django-update-cache-1.0.6.tar.gz
| Download URL | django-update-cache-1.0.6.tar.gz |
|---|---|
| Size | 116.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
efba2e8fe25ec143ce034180602205eec4619045a3f39146d6dcc54ca8ef668f
|
|
BLAKE2b-256 checksum How to use checksums |
d53176c09005a2c451bf142afbddd231d9c597eafed44669d3a112d95387da07
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|
Release files / django_update_cache-1.0.6-py3-none-any.whl
| Download URL | django_update_cache-1.0.6-py3-none-any.whl |
|---|---|
| Size | 11.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a86f761f41272242ad579cabd20e9aab285debf22d18d95aead7bf6237af90cf
|
|
BLAKE2b-256 checksum How to use checksums |
2c4cec7456a18b71a125b9fc0551fce0484cebc09a5a4874ab71ea05c1174988
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|
Security for django-update-cache 1.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.