Simple Redis-based Cache library for Node.js
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
.gitignore
README.md
index.js
package.json

README.md

SPCache

Simple Cache library, using redis as memstore.

Usage

var SPCache = require('spcache');
var cache = new SPCache({
    // configuration
    ttl: (3600 * 24) // cache for 24 hours
    pfx: 'spcache' // redis key prefix
});

// Adding objects (objects will be converted to json)
cache.add({ name: "object name", text: "Lorem Ipsum" }, "object ID");

// Fetch all object
cache.fetch(function(err, results) {
    console.log(results);
});

// Fetch all objects between an 5 hours ago, and ten minutes ago.
var now  = new Date().getTime();
var from = now - ((5 * 3600) * 1000);
var to   = now - 600000;

cache.fetch(from, to, function(err, results) {
    console.log(results);
});