rc
rc - the redis cache.
easy to use
can build cache cluster
batch-fetch multiple cache results (do it in parallel for cluster)
For full documentation see rc.readthedocs.org.
Installation
$ pip install rc
Quickstart
A minimal cache example looks like this:
from rc import Cache
cache = Cache()
assert cache.set('key', 'value')
assert cache.get('key') == 'value'
assert cache.get('foo') is None
assert cache.set('list', [1])
assert cache.get('list') == [1]
A cache cluster use a redis cluster as backend:
from rc import CacheCluster
cache = CacheCluster({
'cache01': {'host': 'redis-host01'},
'cache02': {'host': 'redis-host02'},
'cache03': {'host': 'redis-host03'},
'cache04': {'host': 'redis-host04', 'db': 1},
})
Cache decorator:
@cache.cache()
def load(name, offset):
return load_from_database(name, offset)
rv = load('name', offset=10)
Batch fetch multiple cache results:
assert cache.get_many('key', 'foo') == ['value', None]
# for cache decorated function
@cache.cache()
def cached_func(param):
return param
results = []
# with the context manager, the function
# is executed and return a promise
with cache.batch_mode():
for i in range(10):
results.append(cached_func(i))
for i, rv in enumerate(results):
assert rv.value == i
Cache invalidation:
cache.delete('key')
# for decorated function
cache.invalidate(load, 'name', offset=10)
Better
If you feel anything wrong, feedbacks or pull requests are welcome.
Metadata
Release files for rc 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 |
|---|---|---|---|---|
| rc-0.3.1.tar.gz | 12.1 kB | Without provenance | Details for rc-0.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rc-0.3.1-py2-none-any.whl | Python 2 | none | any | Details for rc-0.3.1-py2-none-any.whl |
Total release size: 27.6 kB
Release files / rc-0.3.1.tar.gz
| Download URL | rc-0.3.1.tar.gz |
|---|---|
| Size | 12.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dd45ca7c37f383aba3cdf7fccf5fff0f5b6eacb70d7ca75532ac9410be2a0151
|
|
BLAKE2b-256 checksum How to use checksums |
395d82bce78023c470345d27b61cb3f1bc4fdc8249dcd7d83bc05b1319687adf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / rc-0.3.1-py2-none-any.whl
| Download URL | rc-0.3.1-py2-none-any.whl |
|---|---|
| Size | 15.4 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
e6446eac03afd75e6198d6a4e1acd4f569d914a2cc908bdb849f022a3e346fa0
|
|
BLAKE2b-256 checksum How to use checksums |
6c0f70df511b9ee2ac982ef1a4d422b0a6c2391fda1d9de4cd038f3f2e69a43f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for rc 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.