Last active
December 11, 2015 17:49
-
-
Save jgoodall/4637526 to your computer and use it in GitHub Desktop.
redis pub sub in node (using [redis module](https://github.com/mranney/node_redis))
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var redis = require('redis') | |
, rc = redis.createClient() | |
for (var i = 0; i < 10; i++) { | |
var msg = 'message ' + i | |
console.log('publishing message: ' + msg) | |
rc.publish('test', msg) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var redis = require('redis') | |
, rc = redis.createClient() | |
rc.on('subscribe', function (channel, count) { | |
console.log('subscribed to channel ' + channel + ' (' + count + ')') | |
}) | |
rc.on('message', function (channel, msg) { | |
console.log(msg) | |
}) | |
rc.subscribe('test') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment