Skip to content

Instantly share code, notes, and snippets.

@jcuffe
Created September 4, 2012 22:48
Show Gist options
  • Save jcuffe/3627626 to your computer and use it in GitHub Desktop.
Save jcuffe/3627626 to your computer and use it in GitHub Desktop.
var uuid = require('node-uuid'),
redis = require('redis'),
client = redis.createClient();
exports.create = function(data, callback) {
var key = uuid.v1.slice(0, 8);
return client.setnx(key, callback);
};
exports.load = function(id, callback) {
return client.get(id, function(error, response) {
if (response == null) {
console.log(id + " not found");
client.get('default', callback);
} else {
callback(error, response);
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment