timed-cache
Pure Python timed-cache that behaves like a regular dict.
Can also be used as a decorator to cache function calls (works for async functions as well).
Installation
pip install py-timed-cache
Example
from timedcache import TimedCache
my_cache = TimedCache(1) # 1 second cache
my_cache["foo"] = "bar" # all dict methods works as if it was a normal dict
for k, v in my_cache.items():
print(k, v) # will print foo bar
# Also works for functions
@TimedCache(5)
def foo(number):
# some expensive compute...
print("begin computation...")
result = number * 10**30
print("end computation")
return res
big_number = foo(42) # cache MISS ==> this will print both statements above
big_number_again = foo(42) # Called with same argument(s) ==> cache HIT, returns immediately
Python versions
Python >= 3.6 are supported
Tests
This project uses unittest.
Run python tests/test_timedcache.py
Metadata
Release files for py-timed-cache 1.0.2
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 |
|---|---|---|---|---|
| py-timed-cache-1.0.2.tar.gz | 3.7 kB | Without provenance | Details for py-timed-cache-1.0.2.tar.gz |
Release files / py-timed-cache-1.0.2.tar.gz
| Download URL | py-timed-cache-1.0.2.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c30445220261a2fa2c049f51648b22af94b1273bde1e3f2f189c3e4012f2b89e
|
|
BLAKE2b-256 checksum How to use checksums |
8f87e717964fe732bf0bc83396458d01d99654772b5ed722b6574486a3134efc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.0
|
Security for py-timed-cache 1.0.2
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.