quick_cache
A quick and easy to use python caching system.
You can install quick_cache via
pip install --user quick_cache
and import it in python using:
from quick_cache import QuickCache
Create the cache object as follows:
def msg(message, *args, **kwargs):
print(message.format(*args, **kwargs), file=sys.stderr)
cache = QuickCache(base_file, quota=500, ram_quota=100, warnings=msg)
where base_file is an optional file whose content invalidates the cache (ie., when the content of the file changes the cache is invalidated; for large files it might be desirable to use the mtime in the cache object below) and msg is an optional formatting function that prints warnings (by default it’s None which doesn’t print anything; warnings are emitted when the actual computation is faster than reading the results from the cache or if other exceptional situations occur). quota and ram_quota are optional maximal cache sizes, both in RAM and on disk, in MB.
The caching functionality can then be used via:
with cache.get_hnd({
# object identifying the task to cache
# can be any combination of keys and values
"param_a": 5,
"input_file_c": os.path.getmtime(input_file_c), # for file change time
...
}) as hnd:
if not hnd.has():
res = hnd.write(do_compute()) # compute your result here
else:
res = hnd.read()
# your result is in res
The cache object used for creating the handle uniquely defines the task. The object should contain all parameters of the task and the task computation itself should be deterministic.
Metadata
Release files for quick-cache 0.3.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 |
|---|---|---|---|---|
| quick_cache-0.3.1.tar.gz | 7.5 kB | Without provenance | Details for quick_cache-0.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| quick_cache-0.3.1-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for quick_cache-0.3.1-py2.py3-none-any.whl |
Total release size: 14.5 kB
Release files / quick_cache-0.3.1.tar.gz
| Download URL | quick_cache-0.3.1.tar.gz |
|---|---|
| Size | 7.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c600bdd266b4964728f6bcb466327ed7323487b854fdbdd48c15170f1f81327e
|
|
BLAKE2b-256 checksum How to use checksums |
60b6cd7e97cf4affb91c92a9680aea04260d3ce96a46b2a964becf5086ccbe41
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / quick_cache-0.3.1-py2.py3-none-any.whl
| Download URL | quick_cache-0.3.1-py2.py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
9599c99f9e1f7602790b85e233c49a970f2121c5895e218453fbcee1939f5099
|
|
BLAKE2b-256 checksum How to use checksums |
7b43b8cc225f451c8906d358e155d25fd2fafc0eb9d3646befacf14d4f3a3341
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for quick-cache 0.3.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.