Important Note :
This repo is widely based on https://github.com/louisLouL/louisPy Yet, for deployment purposes (esp. AWS Lambda), it relies too heavily on pandas.
Quick start
Install
pip install rediscache_decorator
Initialize
from rediscache_decorator import Cache
from redis import StrictRedis
redis = StrictRedis(decode_responses=True)
cache = Cache(redis)
Examples
Make sure you have redis up and running.(https://redis.io/)
Example1 : Cache string return
from time import sleep
from datetime import datetime
@cache.ttl(300)
def pseudo_calc():
sleep(1)
print("Computation in progress")
return str(datetime.now())
for i in range(10):
print(pseudo_calc())
Example 3: Cache dict
@cache.dict(60)
def return_a_dict(*args, **kwargs):
sleep(1)
print("Computation in progress")
return {"now": str(datetime.now())}
for i in range(5):
print(return_a_dict())
Example 4: Cache float number
@cache.float(60)
def return_a_float(*args, **kwargs):
return random()
for i in range(5):
print(return_a_float())
Delete Cache
# Delete cache by function and signature
cache.delete_cache(return_a_float, 2, b=3)
# Delete cache by function
cache.delete_cache(return_a_float)
# Delete all caches
cache.delete_cache()
Metadata
Release files for rediscache-decorator 1.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 | Actions |
|---|---|---|---|---|
| rediscache_decorator-1.0.tar.gz | 2.9 kB | Without provenance | Details for rediscache_decorator-1.0.tar.gz |
Release files / rediscache_decorator-1.0.tar.gz
| Download URL | rediscache_decorator-1.0.tar.gz |
|---|---|
| Size | 2.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c9cac950029991e70211b5b6118b3a1e06f027895bb23023cdecbefcf2e7fca8
|
|
BLAKE2b-256 checksum How to use checksums |
62042cc0a1b6acc7e5eb4a6e68f2afdff022010b8713f8e26bbfd474355ad2fa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.5
|
Security for rediscache-decorator 1.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.