Prolog
Django-context-cache extends the Django framework with a context cache that caches data per request or per decorated block.
Installation
- Install
django-context-cachewith thepipcommand:
pip install django-context-cache
- Add
'context_cache.middleware.ContextCacheMiddleware'to yourMIDDLEWARE:
MIDDLEWARE = [
'context_cache.middleware.ContextCacheMiddleware',
...
]
Usage
Imagine having an function or method which result you want to cache per request:
import random
import string
from context_cache.decorators import cache_for_context
@cache_for_context
def get_random_string():
letters = string.ascii_lowercase
return ''.join(random.choice(letters) for i in range(10))
If you call function get_random_string more times the value will be get from cache:
def view(request):
get_random_string() == get_random_string() # should return True
If you want to cache an function out of requests, for example in the django command you can use the decorator init_context_cache. The decorator can be used as a context processor too:
from django.core.management.base import BaseCommand, CommandError
from context_cache.decorators import init_context_cache
class Command(BaseCommand):
@init_context_cache
def handle(self, *args, **options):
get_random_string() == get_random_string() # should return True
Metadata
Release files for skip-django-context-cache 0.0.2.1
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 |
|---|---|---|---|---|
| skip-django-context-cache-0.0.2.1.tar.gz | 8.7 kB | Without provenance | Details for skip-django-context-cache-0.0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| skip_django_context_cache-0.0.2.1-py3-none-any.whl | Python 3 | none | any | Details for skip_django_context_cache-0.0.2.1-py3-none-any.whl |
Total release size: 19.3 kB
Release files / skip-django-context-cache-0.0.2.1.tar.gz
| Download URL | skip-django-context-cache-0.0.2.1.tar.gz |
|---|---|
| Size | 8.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7033051e6bbed5a41d63064b8c1af7ec3ce0e88677cec9de8a4b29a698922041
|
|
BLAKE2b-256 checksum How to use checksums |
97068e1e88fda41a2f26076fc9484360d76984a3a07f7235b9be8ab62ae15f7b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.1
|
Release files / skip_django_context_cache-0.0.2.1-py3-none-any.whl
| Download URL | skip_django_context_cache-0.0.2.1-py3-none-any.whl |
|---|---|
| Size | 10.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9a0cac4a748eca83ec8093fd9be6c15c1abd9fa5ccb8adeb73d89158b89bcba1
|
|
BLAKE2b-256 checksum How to use checksums |
42dec568162b9d4ce8526af1920d27f017492cde91307cbeb05d755e777ec3d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.1
|
Security for skip-django-context-cache 0.0.2.1
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.