Skip to content

Instantly share code, notes, and snippets.

@waggertron
Forked from reu/pub-sub.js
Created February 15, 2017 04:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save waggertron/00f328b0c3a0a62f514156449b9eb472 to your computer and use it in GitHub Desktop.
Save waggertron/00f328b0c3a0a62f514156449b9eb472 to your computer and use it in GitHub Desktop.
node.js redis pub-sub example
var redis = require("redis")
, subscriber = redis.createClient()
, publisher = redis.createClient();
subscriber.on("message", function(channel, message) {
console.log("Message '" + message + "' on channel '" + channel + "' arrived!")
});
subscriber.subscribe("test");
publisher.publish("test", "haaaaai");
publisher.publish("test", "kthxbai");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment