/tornado-redis

Asynchronous Redis client that works within Tornado IO loop.

Primary LanguagePythonOtherNOASSERTION

Tornado-Redis

Asynchronous Redis client that works within Tornado IO loop.

This is basically a fork of brükva redis client slightly modified to work with tornado.gen interface instead of adisp.

Usage

import tornadoredis
import tornado.web
import tornado.gen

...	

c = tornadoredis.Client()
c.connect()

...

class MainHandler(tornado.web.RequestHandler):
    @tornado.web.asynchronous
    @tornado.gen.engine
    def get(self):
        foo = yield tornado.gen.Task(c.get, 'foo')
        bar = yield tornado.gen.Task(c.get, 'bar')
        zar = yield tornado.gen.Task(c.get, 'zar')
        self.set_header('Content-Type', 'text/html')
        self.render("template.html", title="Simple demo", foo=foo, bar=bar, zar=zar)

Tips on testing

Run redis-server on localhost:6379. Run tests with the following command:

python -m tornado.testing tornadoredis.tests

Reconnect tests have been disabled by default.

Credits

brukva is developed and maintained by Konstantin Merenkov

License

See LICENSE file. Long story short: WTFPL v2