redis-cached

A cache wrapper with redis

npm install redis-cached
2 downloads in the last week
4 downloads in the last month

Redis Cached

Provide a function wrapper for to cache return vals into redis.

Only support async calls.

Usage

var Redis = require('redis');
var Cached = require('redis-cached');

var client = Redis.createClient();
var cached = Cached(client, {
  ttl: 60000, // cache will expire in one minutes
  prefix: 'myapp-'
});


var getUser = function(user_id, callback) {

  // do something
  // ...

  callback(err, data);
}

getUser = cached.wrap(getUser, 'user-{0}');
npm loves you