Simple python interface for redis
Project description
Simple python interface for redis
Installation
pip install redistore
Usage
>> import redistore
>> store = redistore.get(host='localhost', port=6379, db=0)
Now you can access and store keys and values with a dict-like interface:
>> store['foo'] = 'bar'
>> store['foo']
'bar'
>> 'foo' in store
True
>> del store['foo']
>> store['foo']
...
KeyError: 'foo'
Or using methods:
>> store.set('baz', 'qux')
>> store.get('baz')
'qux'
redistore support other data types, e.g., hashes. they are used exactly like a dict:
>> store['hash'] = {} # creates a hash without any values
>> 'my' in store['hash']
True
>> store['hash']['my']
'hash'
>> store['hash'].update({'baz': 'qux'})
>> store['hash']['baz']
'qux'
>> len(store['hash'])
2
>> list(store.keys())
['foo', 'bar']
>> for key, value in store.items():
... print(key, value)
...
my hash
baz qux
>> store['other_hash'] = {'foo': 'bar'} # creates a hash with values
>> store['other_hash']['foo']
'bar'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
redistore-0.1.0.tar.gz
(3.3 kB
view details)
File details
Details for the file redistore-0.1.0.tar.gz
.
File metadata
- Download URL: redistore-0.1.0.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c5986a55c39e19b12bc9710fb50f8add3798de4e43a84b1785a0a31df1dcbd8 |
|
MD5 | dd11fadd79660fd9eed28501aba309cc |
|
BLAKE2b-256 | 6ca73ce0ac61fde72353dcb5776a2c20a15c036e3ebb75dc1f3768bb32900b72 |