Direct-Redis
- Serialize any python datatypes and executes redis commands using redis-py
- When loading, it auutomatically converts serialized data into original data types
Getting Started
Install via pypi
pip install direct-redis
Instantiate
from direct_redis import DirectRedis
r = DirectRedis(host='localhost', port=6379)
Supporting Data Types
- Built-in
- string
- number(int, float)
- dictionary
- list
- tuple
- etc (all other python built-in types)
- Module Classes
- pandas
- numpy
Supporting Redis Commands
Direct-Redis Supports
- Basic Functions
- KEYS
- RANDOMKEY
- TYPE
- SET
- GET
- Hash Functions
- HKEYS
- HSET
- HMSET
- HGET
- HMGET
- HGETALL
- HVALS
- Set Functions
- SADD
- SREM
- SMEMBERS
- SPOP
- SDIFF
- SCARD (Default)
- SRANDMEMBER
- List Functions
- LPUSH
- RPUSH
- LPUSHX
- RPUSHX
- LRANGE
- LPOP
- RPOP
- LINDEX
Examples
String
- Originally redis stores string into bytes.
>>> s = "This is a String. \n스트링입니다."
>>> print(s)
This is a String.
스트링입니다.
>>> r.set('s', s)
>>> r.get('s')
'This is a String. \n스트링입니다.'
>>> type(r.get('s'))
<class 'str'>
Numbers
>>> mapping = {
... 'a': 29,
... 'b': 0.5335113,
... 'c': np.float64(0.243623466363223),
... }
>>> r.hmset('nums', mapping)
>>> r.hmget('nums', *mapping.keys())
[29, 0.5335113, 0.243623466363223]
>>> list(mapping.values()) == r.hmget('nums', *mapping.keys())
True
Nested Dictionaries and Lists
>>> l = [1,2,3]
>>> d = {'a': 1, 'b': 2, 'c': 3}
>>> r.hmset('list and dictionary', {'list': l, 'dict': d})
>>> r.hgetall("list and dictionary")
{'list': [1, 2, 3], 'dict': {'a': 1, 'b': 2, 'c': 3}}
>>> type(r.hgetall("list and dictionary")['list'])
<class 'list'>
>>> type(r.hgetall("list and dictionary")['dict'])
<class 'dict'>
Pandas DataFrame
>>> df = pd.DataFrame([[1,2,3,'235', '@$$#@'],
['a', 'b', 'c', 'd', 'e']])
>>> print(df)
0 1 2 3 4
0 1 2 3 235 @$$#@
1 a b c d e
>>> r.set('df', df)
>>> r.get('df')
0 1 2 3 4
0 1 2 3 235 @$$#@
1 a b c d e
>>> type(r.get('df'))
<class 'pandas.core.frame.DataFrame'>
Numpy Array
>>> arr = np.random.rand(10).reshape(5, 2)
>>> print(arr)
[[0.25873887 0.00937433]
[0.0472811 0.94004351]
[0.92743943 0.93898677]
[0.87706341 0.85135288]
[0.06390652 0.86362001]]
>>> r.set('a', arr)
>>> r.get('a')
array([[0.25873887, 0.00937433],
[0.0472811 , 0.94004351],
[0.92743943, 0.93898677],
[0.87706341, 0.85135288],
[0.06390652, 0.86362001]])
>>> type(r.get('a'))
<class 'numpy.ndarray'>
Author
direct-redis is developed and maintained by Yonghee Cheon (yonghee.cheon@gmail.com).
It can be found here: https://github.com/yonghee12/direct-redis
Special thanks to:
- Andy McCurdy, the author of redis-py.
Metadata
Release files for direct-redis 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 | |
|---|---|---|---|---|
| direct_redis-0.3.1.tar.gz | 4.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| direct_redis-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.9 kB
Release files / direct_redis-0.3.1.tar.gz
| Download URL | direct_redis-0.3.1.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b71c405d28a0d6996ddc7abd4e43055646fed8737b9706e14a0432f5bf898608
|
|
BLAKE2b-256 checksum How to use checksums |
fd441c2952b7c84714d617ffbf9eb2b94a3403388012691133692a4502e5aa7b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.0 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.6
|
Release files / direct_redis-0.3.1-py3-none-any.whl
| Download URL | direct_redis-0.3.1-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
84642890daddc0335219e9246d0ddb4387ea2d25f2bb6da49d3cc0ba640e539e
|
|
BLAKE2b-256 checksum How to use checksums |
4060b54bd840970c8ed3a13d19ff0dad6af036c5bf6b211c5ce8cf4831ea5092
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.0 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.6
|
Security for direct-redis 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.