Skip to content

Instantly share code, notes, and snippets.

@erkanzileli
Created November 28, 2019 07:44
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 erkanzileli/709ce1e7fcc8fe8dddaeaeee88138f66 to your computer and use it in GitHub Desktop.
Save erkanzileli/709ce1e7fcc8fe8dddaeaeee88138f66 to your computer and use it in GitHub Desktop.
const redis = require('redis')
const publisher = redis.createClient()
const subscriber = redis.createClient()
subscriber.psubscribe('channel:*')
subscriber.on('psubscribe', console.log)
subscriber.on('pmessage', (pattern, channel, message) => console.log(`pattern: ${pattern}, channel: ${channel}, message: ${message}`))
let counter = 0
setInterval(() => {
++counter
publisher.publish(`channel:${counter}`, `message${counter}`)
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment