I have a simple example:
c = tornadoredis.Client()
c.connect()
class SourceHandler(tornado.web.RequestHandler):
@tornado.web.asynchronous
@tornado.gen.engine
def get(self):
pipe = c.pipeline(transactional=True)
pipe.zadd( 'test1'), 1212, "test" )
pipe.zadd( 'test2'), 1212, "test" )
.....
pipe.zadd( 'testN'), 1212, "test" )
res = yield tornado.gen.Task(pipe.execute)
self.set_header('Content-Type', 'text/html')
self.render("template.html", title="result")
time for this request = N * time for zadd operation.
Can I decrease time for this request ?
A pipeline request is a transactional request which requires that all operations within it execute as an atomic unit. The statement –
res = yield tornado.gen.Task(pipe.execute)will wait until all of thezaddstatements are executed until it returns execution back to your get(…) function.The only way that you could decrease execution time is to remove the
gen.enginebits in a fire and forget pattern, though you’ll no longer have any response information.