08.10.2012 15:57, mrtn пишет:
I just wonder, how it is possible, that such library uses blocking call
socket.connect to establish the connection and has no mechanisms to
execute transactions properly. These problems caused me to doubt the
reliability of the rest of the code.
> * straight Redis API
> * flexible connection pool, not requiering you to establish a redis
> connection every time when you need to execute a transaction in
> asychronous HTTP request handler
> * permanent request pipelining
> Does it support all the latest commands available in Redis 2.4+?
Yes, it should. Python API for Redis commands (RedisCommandsMixin in
commands.py) is generated automatically from http://redis.io/commands.json
. Though I have not tested it yet, but
looks like all commands should work correctly. Except commands, which
affects the execution of other commands, which are following them
(actually these commands are WATCH, MULTI and SELECT). Execution of such
commands is disabled for consistency, in case if you did not pick up the
connection from the pool, with "locking" this connection.
> Could you please tell what you mean by permanent request pipelining? A
> use case example would be nice.
All commands are sent to one of the shared redis connections in pool
asynchronously, in tornado way. They are sent immediately (or when the
new connection to redis would be established, if there are no
connections in shared pool). If there are several connections in shared
pool, then they are used in round-robin. Toredis maintains a
command/callback queue in the Connection class instance, and when the
data is coming from the socket, it passing the result, obtained from
hiredis.gets(), to the first callback in queue.
> Lastly, how fast is toredis compared to brukva and tornado-redis?
It should be faster, but I have not made any benchmarks yet.