Skip to content
This repository has been archived by the owner on Jun 13, 2019. It is now read-only.
/ easy-cache Public archive

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

Notifications You must be signed in to change notification settings

zonetti/easy-cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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')); // 'bar'
console.log(cache.size()); // 1
cache.unset('foo');
console.log(cache.get('foo')); // null
console.log(cache.size()); // 0

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

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

Credits

Inspired by node-cache.

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published