Skip to content

Instantly share code, notes, and snippets.

@aadityabhatia
Created December 31, 2018 06:27
Show Gist options
  • Select an option

  • Save aadityabhatia/0e9bfb076db33cbb3c964b6c5d375e57 to your computer and use it in GitHub Desktop.

Select an option

Save aadityabhatia/0e9bfb076db33cbb3c964b6c5d375e57 to your computer and use it in GitHub Desktop.
Watch Redis pub/sub channels
redis = require 'redis'
client = redis.createClient
HOST: process.env.HOST
client.on 'error', (err) -> console.error err
client.on 'subscribe', (channel, count) ->
console.log "Subscribed:", channel
client.on 'message', (channel, message) ->
console.log channel, message
client.on 'psubscribe', (pattern, count) ->
console.log "Subscribed:", pattern
client.on 'pmessage', (pattern, channel, message) ->
console.log channel, message
if process.argv.length > 2
for channel in process.argv.slice 2
client.subscribe channel
else
client.psubscribe '*'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment