Skip to content

Instantly share code, notes, and snippets.

@jgoodall
Last active December 11, 2015 17:49
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 jgoodall/4637526 to your computer and use it in GitHub Desktop.
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))
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)
}
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