Skip to content

Instantly share code, notes, and snippets.

@ciberch
Created May 22, 2012 19:30
Show Gist options
  • Select an option

  • Save ciberch/2771117 to your computer and use it in GitHub Desktop.

Select an option

Save ciberch/2771117 to your computer and use it in GitHub Desktop.
Publishing and Activity to Redis
var redis = require("redis");
var publisher = redis.createClient(options.redis.port, options.redis.host);
if(options.redis.pass) {
publisher.auth(options.redis.pass);
}
function publish(streamName, activity) {
activity.save(function(err) {
if (!_.isArray(activity.streams)) {
activity.streams = []
}
if (!_.include(activity.streams, streamName)) {
activity.streams.push(streamName);
}
if (!err && streamName && publisher) {
// Send to Redis PubSub
publisher.publish(streamName, JSON.stringify(activity));
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment