how to use redis PUBLISH/SUBSCRIBE with nodejs by event driven?

997 views
Skip to first unread message

jason.桂林

unread,
Dec 14, 2010, 9:54:53 PM12/14/10
to nod...@googlegroups.com
how to use redis PUB/SUB with nodejs by event driven, I need an example, just like something like a chatroom or anything else.

--
Best regards,

Jason Green
桂林


Shripad K

unread,
Dec 14, 2010, 10:01:40 PM12/14/10
to nod...@googlegroups.com
Check this:


Specifically see socket.io/lib/client.js



--
You received this message because you are subscribed to the Google Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.

jason.桂林

unread,
Dec 14, 2010, 11:44:03 PM12/14/10
to nod...@googlegroups.com
Excellent. It looks very like socket.io,  is it a fork of Socket.IO-node

Shripad K

unread,
Dec 15, 2010, 12:52:41 AM12/15/10
to nod...@googlegroups.com
Yes it is a fork of socket.io :) Sorry for no documentation. I will be adding it shortly. However, you can try the modified example app and also look at client.js and listener.js for the modifications.

Nikhil Marathe

unread,
Dec 15, 2010, 1:01:32 AM12/15/10
to nod...@googlegroups.com
On Wed, Dec 15, 2010 at 8:24 AM, jason.桂林 <gui...@gmail.com> wrote:
> how to use redis PUB/SUB with nodejs by event driven, I need an example,
> just like something like a chatroom or anything else.

Here is a simple example https://gist.github.com/374881

Nikhil

Matt Ranney

unread,
Dec 15, 2010, 1:18:22 AM12/15/10
to nod...@googlegroups.com
On Tue, Dec 14, 2010 at 6:54 PM, jason.桂林 <gui...@gmail.com> wrote:
how to use redis PUB/SUB with nodejs by event driven, I need an example, just like something like a chatroom or anything else.

The node_redis test suite has a simple example of publish/subscribe:


as well as most other things you can do with Redis.

jason.桂林

unread,
Dec 15, 2010, 1:30:01 AM12/15/10
to nod...@googlegroups.com
BTW, which node redis client should I use, I saw a lot redis client module for node in node wiki page.

2010/12/15 Matt Ranney <m...@ranney.com>

--
You received this message because you are subscribed to the Google Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.

Shripad K

unread,
Dec 15, 2010, 1:34:26 AM12/15/10
to nod...@googlegroups.com
Use Matt's node_redis :) Its fast. Socket.IO-PubSub uses that.

2010/12/15 jason.桂林 <gui...@gmail.com>

jason.桂林

unread,
Dec 15, 2010, 1:46:08 AM12/15/10
to nod...@googlegroups.com

Matt Ranney

unread,
Dec 16, 2010, 1:35:15 AM12/16/10
to nod...@googlegroups.com
On Tue, Dec 14, 2010 at 10:46 PM, jason.桂林 <gui...@gmail.com> wrote:

Well, that's the one I use.  :)

If you run into issues with it, there is usually good support available on IRC or through an issue on github.

jason.桂林

unread,
Dec 23, 2010, 1:13:44 PM12/23/10
to nod...@googlegroups.com
Here are typical results of multi_bench.js which is similar to redis-benchmark from the Redis distribution. It uses 50 concurrent connections with no pipelining.
The performance of node_redis improves dramatically with pipelining.
how to use pipelinling?

2010/12/16 Matt Ranney <m...@ranney.com>

--
You received this message because you are subscribed to the Google Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.

Matt Ranney

unread,
Dec 23, 2010, 10:22:19 PM12/23/10
to nod...@googlegroups.com
2010/12/23 jason.桂林 <gui...@gmail.com>
how to use pipelinling?

Pipelining will just happen automatically in node under certain circumstances, because everything in node is non-blocking.  In many Redis clients, you need to wait for a response from every command before you can send another one.  In node_redis, you can send as many as you like as fast as you like, without waiting for them to complete.

Reply all
Reply to author
Forward
0 new messages