Skip to content

Instantly share code, notes, and snippets.

@alejandro
Created August 21, 2011 15:21
Show Gist options
  • Select an option

  • Save alejandro/1160736 to your computer and use it in GitHub Desktop.

Select an option

Save alejandro/1160736 to your computer and use it in GitHub Desktop.
Snippet to connect to your REDIS TO GO instance
var redis = require('redis');
var createRedisClient = function() {
var db = redis.createClient(INSERT_PORT, HOST);
var dbAuth=function() { db.auth('PASSWORD');};
db.addListener('connected',dbAuth);
db.addListener('reconnected',dbAuth);
dbAuth();
return db;
};
exports.redis = createRedisClient();
@alejandro

Copy link
Copy Markdown
Author

Then

In app.js

var redis = require('common').redis;
redis.set('KEY', 'YOUR_AWESOME_VALUE', function(err, res){ 
    console.log(res)  // OK
});
redis.get('KEY', function(err, res){ 
    console.log(res)  // YOUR_AWESOME_VALUE
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment