How can I pop objects from Redis as they are added realtime?
node.js, redis
Solution
You'll want to use a blocking pop: http://redis.io/commands/brpop
function waitForPush () {
client.brpop(['list','otherlist',0], function (listName, item) {
// do stuff
waitForPush();
});
}
Problem
I want to get a Node.js process running as it's checking a Redis server for anything new to pop. Another process will be doing the pushing sporadically, and the Node process will be trying to pop whatever that comes in. The Node process will stay running. Can anyone point me to a good direction? I'm trying to figure out how to listen for such event. Sure, I can pop it once, but how do I get Node process to keep listening for any addition to Redis server?