Skip to content

Instantly share code, notes, and snippets.

@Southern
Created January 21, 2013 15:52
Show Gist options
  • Save Southern/4586993 to your computer and use it in GitHub Desktop.
Save Southern/4586993 to your computer and use it in GitHub Desktop.
REDIS_URL = process.env.REDIS_URL || 'redis://localhost:6379'; // global const for redis
var connection = require("url").parse(REDIS_URL); // parse redis url
REDIS_PARAMS = {}; // global const for redis connection settings, also used by socket.io
REDIS_PARAMS.port = connection.port;
REDIS_PARAMS.host = connection.hostname;
// connect to redis so we can put the express session there
var client = redis.createClient(REDIS_PARAMS.port, REDIS_PARAMS.host);
if ( connection.auth ) {
// REDIS_PARAMS.pass = connection.auth.split(":")[1];
REDIS_PARAMS.pass = connection.auth;
client.auth(REDIS_PARAMS.pass, function (err) {
if (err) throw err;
else console.log('authorised to redis at: '+ REDIS_PARAMS.host)
});
} else console.log('connected to redis at: '+ REDIS_PARAMS.host)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment