Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 45 lines (32 sloc) 1.037 kb

easy-cache Build Status

A simple NodeJS module to handle in-memory key/value cache.

Install

npm install easy-cache

Basic usage

var cache = require('easy-cache');

cache.set('foo', 'bar');
console.log(cache.get('foo')); // output: bar
console.log(cache.getSize()); // output: 1
cache.unset('foo'); // remove specific record

cache.set('temporary', 'value', 100); // duration in ms
console.log(cache.get('temporary')); // output: value

setTimeout(function() {
  try {
    console.log(cache.get('temporary')); // throws an exception
  } catch(err) {
    console.log(err.message); // Invalid key: temporary
  }
}, 150);

setTimeout(function() {
  if (!cache.exists('temporary')) {
    console.log('Key does not exist');
  }
  cache.clear(); // remove all records
}, 200);

Credits

Inspired by node-cache.

Something went wrong with that request. Please try again.