Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Simple Redis-based Cache library for Node.js

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 .gitignore
Octocat-spinner-32 README.md
Octocat-spinner-32 index.js
Octocat-spinner-32 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);
});
Something went wrong with that request. Please try again.