Redis Shelve
A Python shelve that uses Redis as storage.
Motivation
In some contexts writing state to files can be hard. Redis can be a more suitable storage solution. If you need a shelve but cannot write to file and if you are friends with Redis already, you can use Redis Shelve.
License
Redis Shelve is licensed under LGPLv3. See the LICENSE file for details.
Installation
pip install redis-shelve
Usage
The behaviour of the Redis shelve should be similar to Python shelve. Instead of a filename, you can pass redis-shelve a redis instance. You can think of the configured redis database being similiar to a file in Python shelve.
import redisshelve
from redis import Redis
redis = Redis(db=15)
shelf = redisshelve.RedisShelf(redis=redis)
shelf['test'] = 'Test'
assert 'Test' == shelf['test']
assert 'Test' == shelf.get('test')
You can also use the redisshelve.open context manager.
with redisshelve.open(redis=redis) as shelf:
shelf['foo'] = 'Bar'
Prefixing keys
By default, the keys you enter in the shelf are used as keys in Redis. If you think this might conflict with existing values, you can prefix your keys.
NB: As a side effect, if you also use writeback, the keys in the shelf's cache are also prefixed.
shelf = redisshelve.RedisShelf(redis=redis, key_prefix='my_prefix')
with redisshelve.open(redis=redis, key_prefix='my_prefix') as shelf:
shelf['foo'] = 'Bar'
More examples.
Please see the tests for more examples.
unprefixed: tests/test_redisshelve_unprefixed.py
prefixed: tests/test_redisshelve_prefixed.py
Metadata
Release files for redis-shelve 1.0.3
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 |
|---|---|---|---|---|
| redis-shelve-1.0.3.tar.gz | 3.3 kB | Without provenance | Details for redis-shelve-1.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| redis_shelve-1.0.3-py3-none-any.whl | Python 3 | none | any | Details for redis_shelve-1.0.3-py3-none-any.whl |
Total release size: 9.2 kB
Release files / redis-shelve-1.0.3.tar.gz
| Download URL | redis-shelve-1.0.3.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aa9a4b180d8a5e2f65278e29b9801100e30c60ab6c5b59d4afa04df0d9d70874
|
|
BLAKE2b-256 checksum How to use checksums |
a4612587e6f649f08f8749abe0aeb9aea3fa969247f9fb97124a13c00d5281cf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4
|
Release files / redis_shelve-1.0.3-py3-none-any.whl
| Download URL | redis_shelve-1.0.3-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1fc8924e610c97f9d2508a66b7ae0e17d608246a06094a1a01029574b5689c54
|
|
BLAKE2b-256 checksum How to use checksums |
5f68495f0efe97037a54109ade4fe84f80cdf8c73a7ad0aee6f12d53bf70983f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4
|
Security for redis-shelve 1.0.3
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.