Hash interface for redis-py
Project description
Simple python interface for redis hash type
Installation
pip install redis redis_hash
Usage
First you need to instantiate the redis client from the redis package:
>> from redis import StrictRedis
>> redis_client = StrictRedis(host='localhost', port=6379, db=0)
Then create your hash passing the client and the hash key:
>> from redis_hash import RedisHash
>> redis_hash = RedisHash(redis_client, 'hash_name')
Now your can handle your hash like a dict:
>> redis_hash['foo'] = 'bar'
>> len(redis_hash)
1
>> 'foo' in redis_hash
True
>>> for k, v in redis_hash:
... print(k, v)
...
foo bar
>>> redis_hash['foo']
b'bar'
>>> list(redis_hash)
[(b'foo', b'bar')]
>> del redis_hash['foo']
>> len(redis_hash)
0
>> 'foo' in redis_hash
False
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
redis-hash-1.0.1.tar.gz
(2.9 kB
view details)
File details
Details for the file redis-hash-1.0.1.tar.gz
.
File metadata
- Download URL: redis-hash-1.0.1.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2cbf242971989821c057fb12179dc2ab3c45d5642f7f865df29f1918781cb785 |
|
MD5 | 3a7a7f77b9abdc6d9edf663740c4b556 |
|
BLAKE2b-256 | 80c1dfe4742691f17cccfdd17e62da711dc20bcb7364ee17d410bd5d0ac354fc |