Redis client

95 views
Skip to first unread message

Gavin M. Roy

unread,
Oct 7, 2012, 12:56:55 PM10/7/12
to Tornado Web Server
I was curious if anyone is still using Brukva as a redis driver with Tornado or are people just using redis-py? Is there anything else out there that is being used as a redis driver?

Regards,

Gavin

mrtn

unread,
Oct 7, 2012, 1:54:19 PM10/7/12
to python-...@googlegroups.com

There is also tornado-redis, which is supposedly a replacement for Brukva. But I too wonder whether it is worth using an async driver for Redis (especially for one that is hosted locally). If not, redis-py seems to be the way to go.

Andrew Grigorev

unread,
Oct 8, 2012, 6:10:30 AM10/8/12
to python-...@googlegroups.com, Gavin M. Roy
07.10.2012 20:56, Gavin M. Roy пишет:
Hi.

Here is my work-in-progress project -
https://github.com/ei-grad/toredis. I looked in brukva and tornado-redis
source code and terrified, and implemented my own redis client. It is
not well-tested yet, but looks already usable. It lacks some features,
like a PubSub implementation suitable for using in tornado (I have not
yet reached the stage where I need it in my project, for which I am
using redis), but basic functionality works fine.

What is implemented:
* 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

There is no README file yet, so look into the source, and may the force
be with you :-).

Comments, suggestions and patches are welcome.

--
Andrew

mrtn

unread,
Oct 8, 2012, 7:57:48 AM10/8/12
to python-...@googlegroups.com, Gavin M. Roy

Hi Andrew,

Your project sounds very promising, but could you please clarify some questions for me?

Here is my work-in-progress project - 
https://github.com/ei-grad/toredis. I looked in brukva and tornado-redis 
source code and terrified, and implemented my own redis client.

Why is this? Which specific aspects of brukva and tornado-redis terrify you? I know they are not extremely fast, but any other negativity about them?

* 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+?

Could you please tell what you mean by permanent request pipelining? A use case example would be nice.

Lastly, how fast is toredis compared to brukva and tornado-redis? 

Thanks a lot!

Andrew Grigorev

unread,
Oct 8, 2012, 9:55:03 AM10/8/12
to python-...@googlegroups.com
08.10.2012 15:57, mrtn пишет:
>
> Hi Andrew,
>
> Your project sounds very promising, but could you please clarify some
> questions for me?
>
> Here is my work-in-progress project -
> https://github.com/ei-grad/toredis
> <https://github.com/ei-grad/toredis>. I looked in brukva and
> tornado-redis
> source code and terrified, and implemented my own redis client.
>
>
> Why is this? Which specific aspects of brukva and tornado-redis
> terrify you? I know they are not extremely fast, but any other
> negativity about them?

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+?
>
3
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.

>
> Thanks a lot!


--
Andrew

Reply all
Reply to author
Forward
0 new messages