Django Function Cache
Cache the results of a function on S3 (and more!).
The function_cache decorator enables flexibility in how cache key is generated.
Example
In your settings.py, you can set up the FUNCTION_CACHE_BACKENDS (defaults to S3FunctionCacheBackend):
# Django Function Cache
# ---------------------
FUNCTION_CACHE_BACKENDS = {
'default': {
'BACKEND': 'function_cache.backends.S3FunctionCacheBackend',
'OPTIONS': {},
}
}
In your code, you can simply use the function_cache decorator
from django.contrib.staticfiles.storage import staticfiles_storage
from function_cache.decorators import function_cache
@function_cache(name='default', keys=('args[0]', 'args[1]', 'k'), storage=staticfiles_storage)
def create_dict(a, b, k=None, _cache_key=None):
print(f'The cache key is <{_cache_key}>.')
return dict(a=a, b=b, k=k)
#end def
def run():
x = create_dict('variable a', 'b', k={'keyword argument': 42})
#end def
Metadata
Release files for function-cache 0.2.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 | |
|---|---|---|---|---|
| function-cache-0.2.0.tar.gz | 3.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| function_cache-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.2 kB
Release files / function-cache-0.2.0.tar.gz
| Download URL | function-cache-0.2.0.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c815ea196df163624c1ebdc557322feda248089b67ab29c5a09ae3d572f8f47d
|
|
BLAKE2b-256 checksum How to use checksums |
74b5518264ac2b8cdd5b781ac4d56b4849d75f279c4f444a1d897d53f9adc058
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3
|
Release files / function_cache-0.2.0-py3-none-any.whl
| Download URL | function_cache-0.2.0-py3-none-any.whl |
|---|---|
| Size | 5.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7c565afb41854da8821ed9021b5b7cf58ff8d44d9b1b8450621017c069625ec4
|
|
BLAKE2b-256 checksum How to use checksums |
171ec275aff28b6e473057f72492b60d8fcb7ddb8f88476a5cfef6f084a58560
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3
|
Security for function-cache 0.2.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.