Py-Redis
A convenience wrapper for the official Python Redis package. Supports the Python context manager protocol and takes care of (de-)serializing data to JSON, as well as helper methods to work on multiple keys.
Object Creation
from pyredis import RedisConnection
# pass everything you would pass to redis.Redis()
redis_args = {
'host': 'localhost',
# 'password': 'my$ecureRed1s',
# 'port': 1234,
}
with RedisConnection(**redis_args) as my_redis:
my_redis.set('key', 'value')
Redis Get and Set
# redis set
with RedisConnection(**redis_args) as my_redis:
my_redis.set('a_sting', 'my_sting value')
my_redis.set('a_list', [1, 4, 3, 2])
my_redis.set('a_dict', {'key_1': 'val_1', 'key_2': 'val_2'})
# redis get
with RedisConnection(**redis_args) as my_redis:
data = my_redis.get('a_dict')
# data is already converted to a dict
print(type(data))
Handle Lists and Dictionaries
from pprint import pprint
# get multiple keys / data
with RedisConnection(**redis_args) as my_redis:
# get all keys that start with a_
pattern = 'a_'
keys = my_redis.get_key_pattern(pattern)
print(f"list of all keys that start with {pattern}: {keys}")
data = my_redis.get_data_for_keys(keys)
print(f"data of all keys that start with {pattern}: {data}")
# or retrieve the data as a key: data dictionary for a specific pattern
print('data as key: data dictionary for a pattern:')
data = my_redis.get_keys('a_')
pprint(data)
# set all entries of a dictionary to redis
data = {'a': 12, 'b': 'myvalue'}
with RedisConnection(**redis_args) as my_redis:
# yo can continue working with the keys
keys = my_redis.set_dict(data)
print(my_redis.get('a'))
print(my_redis.get(keys[1]))
Fallback
# you can always work directly on the redis.Redis() object,
# as you would with the official package,
# by using the RedisConnection.R attribute
with RedisConnection(**redis_args) as my_redis:
print('access redis client through object...')
print(my_redis.R.get('a_dict'))
Metadata
Release files for py-redis 1.1.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 |
|---|---|---|---|---|
| py-redis-1.1.1.tar.gz | 4.1 kB | Without provenance | Details for py-redis-1.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| py_redis-1.1.1-py3-none-any.whl | Python 3 | none | any | Details for py_redis-1.1.1-py3-none-any.whl |
Total release size: 8.5 kB
Release files / py-redis-1.1.1.tar.gz
| Download URL | py-redis-1.1.1.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f64cfa44dcd69af19348234ba96a2a943e3793248dcbdb267bdefb1751f4002f
|
|
BLAKE2b-256 checksum How to use checksums |
17dcf3972b4358680575e5027d2276c5ffc7b592480e212a9c1a02c06bc16bbc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
|
Release files / py_redis-1.1.1-py3-none-any.whl
| Download URL | py_redis-1.1.1-py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c6ec84fc8251398236f1c0b98f6ad09dc61667c29664efb7d44e95dc5763782e
|
|
BLAKE2b-256 checksum How to use checksums |
58bd2c4313dfe3b09e253d64231c3386baca9db6952de7e71996e165428d6e45
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
|
Security for py-redis 1.1.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.