Reputation: 9611
In a web application, if I need to write an event to a queue, I would make a connection to redis to write the event.
Now if I want another backend process (say a daemon or cron job) to process the or react the the publishing of the event in redis, do I need a persistant connection?
Little confused on how this pub/sub process works in a web application.
Upvotes: 19
Views: 12079
Reputation: 1333
I'm not totally sure, but I believe that yes, pub/sub requires a persistent connection.
For an alternative I would take a peek at resque and how it handles that. Instead of using pub/sub it simply adds an item to a list in redis, and then whatever daemon or cron job you have can use the lpop command to get the first one.
Sorry for only giving a pseudo answer and then a plug.
Upvotes: 2
Reputation: 18504
Basically in Redis there are two different messaging models:
I hope this is clear. I suggest you studying the following commands to understand more about Redis and messaging semantics:
Doc for this commands is available at redis.io
Upvotes: 47