Django Request Cache
Django Request Cache provides a cache for each request (within your Django Request/Response cycle).
Quick start
Download and install using pip install
pip install django-request-cache
Add UserForeignKeyMiddleware and RequestCacheMiddleware to your MIDDLEWARE settings like this:
MIDDLEWARE = (
...
'django.contrib.auth.middleware.AuthenticationMiddleware',
...
'django_userforeignkey.middleware.UserForeignKeyMiddleware',
'django_request_cache.middleware.RequestCacheMiddleware',
)
or if you are still using the an older Django version (e.g., Django 1.8) with MIDDLEWARE_CLASSES:
MIDDLEWARE_CLASSES = (
...
'django.contrib.auth.middleware.AuthenticationMiddleware',
...
'django_userforeignkey.middleware.UserForeignKeyMiddleware',
'django_request_cache.middleware.RequestCacheMiddleware',
)
Use the per-request cache as a decorator
from django_request_cache import cache_for_request
@cache_for_request
def do_some_complex_calculation(a, b, c):
print("Calculating... please wait")
return a * b * c
Try it out by executing do_some_complex_calculation multiple times within your request
Attribution
RequestCache and RequestCacheMiddleware (see middleware.py) are from a source code snippet on StackOverflow https://stackoverflow.com/questions/3151469/per-request-cache-in-django/37015573#37015573 created by coredumperror https://stackoverflow.com/users/464318/coredumperror Original Question was posted by https://stackoverflow.com/users/7679/chase-seibert at https://stackoverflow.com/questions/3151469/per-request-cache-in-django copied on 2017-Dec-20
Metadata
Release files for django-request-cache 1.5.0
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 | Actions |
|---|---|---|---|---|
| django-request-cache-1.5.0.tar.gz | 4.6 kB | Without provenance | Details for django-request-cache-1.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_request_cache-1.5.0-py3-none-any.whl | Python 3 | none | any | Details for django_request_cache-1.5.0-py3-none-any.whl |
Total release size: 9.5 kB
Release files / django-request-cache-1.5.0.tar.gz
| Download URL | django-request-cache-1.5.0.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d4659cdc21afececa7e9f9c36afd252dfb189b43bc1af0b1916294deff7868c6
|
|
BLAKE2b-256 checksum How to use checksums |
e008a06444b95cd9fcd637f54a6a35e5c6e878cec0fd4b05b9287486dc10dbce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.8.18
|
Release files / django_request_cache-1.5.0-py3-none-any.whl
| Download URL | django_request_cache-1.5.0-py3-none-any.whl |
|---|---|
| Size | 4.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
31bf8109d260310e144f28f502f16ae0c1ab9bb6bd6ae3b7429cc3f587bb0bd8
|
|
BLAKE2b-256 checksum How to use checksums |
f10f43e799a7524be92137445b13b304b78908eb4bc8eeef65adeb2204a91eeb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.8.18
|
Security for django-request-cache 1.5.0
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.