Skip to content

Instantly share code, notes, and snippets.

@phated
Forked from briancavalier/redis-1.js
Created April 4, 2014 20:43
Show Gist options
  • Save phated/9982756 to your computer and use it in GitHub Desktop.
Save phated/9982756 to your computer and use it in GitHub Desktop.
var node = require('when/node');
var net = require('net');
var RedisClient = require('redis').RedisClient;
var host = '127.0.0.1';
var port = 6379;
var commands = require('redis/lib/commands');
function PromisedRedisClient() {
RedisClient.apply(this, arguments);
}
PromisedRedisClient.prototype = node.liftAll(RedisClient.prototype, function(proto, f, n) {
if(commands.indexOf(n) >= 0) {
proto[n] = f;
}
return proto;
});
var client = new PromisedRedisClient(net.connect(host, port));
client.port = port;
client.host = host;
client.get('foo').done(console.log);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment