Skip to main content

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

dictator-0.1.1.tar.gz (3.1 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page