python 2.7 - Life of redis connection/pipeline? -
i creating redis pipeline below in python:
rpipe = redis.redis(...).pipeline() variable rpipe defined in __init__ of class.
the functions in class execute set , get commands when called user using rpipe.
rpipe.set(...) rpipe.execute() but understand, redis connections closed redis server automatically, how long rpipe valid 1 time created object?
under normal conditions (e.g. unless you're hitting limit on max number of clients or max buffer size, or if client sets specific timeout) redis doesn't close client connections automatically.
pipelines in redis simple way grouping commands , send them server @ once, receiving replies in single step.
assuming you're using redis-py library (but same arguments may reasonably hold thought client), (only) when phone call execute() on pipeline object commands packed , sent redis. state of pipeline object reset , can safely reused client.
as side note, if using redis-py, consider pipelined commands wrapped in multi/exec transaction default, not desirable.
python-2.7 redis
No comments:
Post a Comment