redis-wrapper

Provides a simple class/mixin as base for when you need to wraps a redis client (or provide API that does) via a use() method

REDIS-WRAPPER

Because I wrote this too many times already, I decided to just move it into a small module of its own.

Javascript:

function MyRedisClass() { }
MyRedisClass.prototype = new require('redis-wrapper')()
 
// or mix into a singleton object with underscore 
MySingleton = { funcfunction() { } };
MySingleton = _.extend(MySingleton, new require('redis-wrapper')());

Coffeescript:

class YourClass extends require('redis-wrapper')

Setup your classes with use()

MyClass.prototype = new require('redis-wrapper')();
 
var instance = new MyClass()
  , client = require('redis').createClient();
 
instance.use(client);

Adds ensureClient() before redis-related methods to ensure a client is set.

MyClass.prototype.someMethod = function() {
  this.ensureClient();
 
  // do things with this.client 
};

That's all.

  • Adds ability to use a url (via redis-url) or host/port combination.

BSD