Skip to main content

Really simple async Redis client for Tornado

Project description

TOREDIS
=======

This is minimalistic, but feature rich redis client for Tornado built on top of `hiredis <https://github.com/pietern/hiredis-py>`_ protocol parser.

Supports all redis commands, which are auto-generated from the redis `JSON documentation file <https://github.com/antirez/redis-doc/blob/master/commands.json>`_.

Key design points:

1. While toredis attempts to add some syntactical sugar to the API, all responses are returned "as is". For example, if command returns
list of items and developer requested only one key, list with one entry will be returned. For example::

def handle(self, result):
print(len(result))

conn.hkeys('test1', handle)


2. Most redis commands accept one or more keys. Toredis adds a bit of logic to handle single key or array of keys. Due to python
limitations, it is not possible to use ``*args`` with named ``callback`` argument, so you will have to pass array of key names::

# This will work
conn.blpop('test', callback=callback)
conn.blpop(['test', 'test2'], callback=callback)

# This won't work
conn.blpop('test', 'test2', callback=callback)


3. If redis connection will be dropped while waiting for response, callback will be triggered with `None` as a value.

4. Toredis does not provide reconnection feature, but you can override :meth:`~toredis.Client.on_disconnect` method and implement your reconnection logic.

You can find command `documentation here <https://github.com/mrjoes/toredis/blob/master/toredis/commands.py>`_ (will be moved to rtd later).

Pipelining is also supported::

# For more than one pipeline for connection create it with Pipeline(conn)
pipeline = conn.pipeline()
pipeline.set('foo', 'bar')
pipeline.get('foo')
pipeline.send(callback=callback)

For more examples please refer to tests.
More on `redis pipelining <http://redis.io/topics/pipelining>`_.

Things missing:

* Backport pure-python redis protocol parser (for PyPy support)
* Connection pools

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

toredis-fork-0.1.4.tar.gz (12.0 kB view details)

Uploaded Source

File details

Details for the file toredis-fork-0.1.4.tar.gz.

File metadata

File hashes

Hashes for toredis-fork-0.1.4.tar.gz
Algorithm Hash digest
SHA256 06f1f88bc132fa0e0e148c393b01bb85d7eb8633877300f3ada74d380abaffe4
MD5 e8dbb0d1492050a3da7267e2456182d6
BLAKE2b-256 fb3c1224e002cf9f1d23dad5d5ac0ded131c994d00b50f66ca76198778350bcd

See more details on using hashes here.

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