Redis Backed Cache Facilitator
JavaScript
Switch branches/tags
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
.gitignore
.travis.yml
README.md
index.js
package.json
test.js

README.md

Cachey Travis Build Status Coverage Status Dependency Status

Redis Backed Cache for Node.JS

Features

  • Asynchronous
  • Key/Value Cache
  • Flush a key
  • Flush all keys
  • JSON stringify and parse for storing Objects in Redis

Install

$ npm install cachey

Usage

  1. Create a Redis Client Instance

    var redis = require('redis').createClient();
  2. Require Cachey & Parse in the redis instance

    var cachey = require('cachey')({redisClient:redis});
  3. Start Caching

    cachey.cache(key, ttl, getDataFunction, returnDataFunction)

    Parameters:

    1. key - String - Unique Id for the data your caching
    • ttl - Number - Time (in Seconds) you want to cache data for
    • getDataFunction - Function - The first parameter parsed is a callback with the structure callback(err, data)
    • return DataFunction - Function - Callback that errors, then data.

Examples

Flushing a Key

cachey.flush('beep', function(err, flushed) {
  if(err) throw err;
  console.log('beep was flushed away');
});

Flushing all Keys

cachey.flush(function(err, flushed) {
  if(err) throw err;
  console.log('all keys were flushed');
});

##Testing

$ npm test

##Links

Licence

MIT © Ben Evans