Dictator is a tiny library for Robots to work with Redis as a Dict.
Project description
Dictator is a tiny library for Robots™ to work with Redis as a Dict.
It handles Redis API commands and represent itself as a dict-like object.
Install
$ pip install dictator
Usage
It’s easy to start by creating Dictator object
>>> dc = Dictator(host='localhost', port=6379, db=0)
For the moment it handles not all features of Python Dict but basics:
.set(key, value)
>>> dc.set('Planets', ['Mercury', 'Venus', 'Earth']) >>> dc['Stars'] = ['Sun']
.get(key)
>>> dc['Stars'] ['Sun'] >>> dc.get('Planets') ['Mercury', 'Venus', 'Earth']
You can set default value for get() function just like for a dict-object:
>>> dc.get('Comets', 'No data') 'No data'
.update(other=None, **kwargs)
>>> dc.update({'Stars': ['Sun', 'Vega']}) >>> dc.update(Stars=['Sun'])
.pop(key, default=None)
>>> dc.pop('Stars') ['Sun'] >>> dc.pop('Comets')
.delete(key)
>>> dc.delete('Comets')
or
>>> del dc['Comets']
.keys() and .values()
>>> dc.keys() ['Planets', 'Stars'] >>> dc.values() [['Mercury', 'Venus', 'Earth']]
.items()
>>> dc.iterms() [('Planets', ['Mercury', 'Venus', 'Earth'])]
also it supports iteration via generator object:
.iterkeys()
.itervalues()
.iteritems()
and more
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
File details
Details for the file dictator-0.1.1.tar.gz
.
File metadata
- Download URL: dictator-0.1.1.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3363b3b5059a809edbcceb282bfc8afb2535fac18c666fd7a39c4a58e93fb2b3 |
|
MD5 | fe19cc3822b95dd8f56bbfa88cc9b79c |
|
BLAKE2b-256 | ae83505791da148b2cd814bec3e519a0077a2073d0cf52b32fe466bb591dbcb0 |