django-cache-helper
Overview
django-cache-helper is a simple tool for making caching functions, methods, and class methods a little bit easier. It is largely based off of django-cache-utils, however, since cache-utils did not support caching model methods by instance and carried other features I didn't need, django-cache-helper was created.
In order to cache and invalidate a function/method/class_method/static_method:
Support
| Python |
|---|
| 3.7, 3.8, 3.9, 3.10 |
How to Cache
# Caching a function
@cached(60*60) # 60 Minutes
def foo(bar):
return bar
class Incrementer:
@cached_instance_method(60 * 60)
def instance_increment_by(self, num):
return num
@classmethod
@cached_class_method(60 * 60)
def class_increment_by(cls, num):
return num
@staticmethod
@cached(60 * 60)
def get_datetime():
return datetime.utcnow()
How to invalidate a cache
foo(1)
foo.invalidate(1)
Incrementer.instance_increment_by(1)
Incrementer.instance_increment_by.invalidate(1)
Incrementer.class_increment_by(1)
Incrementer.class_increment_by.invalidate(1)
Incrementer.get_datetime()
Incrementer.get_datetime.invalidate()
How to run tests
-
Create and activate a new Python virtual environment using the package manager of your choice (e.g.,
pyenv-virtualenv,virtualenv, etc.). -
Install requirements.
pip install -r requirements.txt
-
Install the
django_cache_helperpackage in editable modepip install -e .
-
Run tests using
manage.py:cd test_project python manage.py test
Note that the current test suite generates some expected warnings, which are manually suppressed in the test code.
Contributors ✨
Thanks goes to these wonderful people.
Kevin Fox |
Tom Jakeway |
Ara Anjargolian |
Hyuckin David Lim |
James |
Metadata
Release files for django-cache-helper 1.0.8
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_cache_helper-1.0.8.tar.gz | 8.0 kB | Without provenance | Details for django_cache_helper-1.0.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_cache_helper-1.0.8-py3-none-any.whl | Python 3 | none | any | Details for django_cache_helper-1.0.8-py3-none-any.whl |
Total release size: 15.5 kB
Release files / django_cache_helper-1.0.8.tar.gz
| Download URL | django_cache_helper-1.0.8.tar.gz |
|---|---|
| Size | 8.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cf69d635d04e39d6f27eb4db2509c73f05c5490e806e85a89c03bffafaa0ba70
|
|
BLAKE2b-256 checksum How to use checksums |
de50ac003161ee23b9354ac3f36fe79cbc6195b51f49abdc14af58fe8a0432d8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Release files / django_cache_helper-1.0.8-py3-none-any.whl
| Download URL | django_cache_helper-1.0.8-py3-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
95bd413e40bda47af17ce5f0f3473abf95bae8a1d7935ea79309bcb940d25526
|
|
BLAKE2b-256 checksum How to use checksums |
ed9c7584f59939d9041be9aaee309836ef1961d00c498ed8d332fbf10caeff01
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Security for django-cache-helper 1.0.8
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.