Skip to content

marcusphillips/make_cache.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

makeCache allows you to generate caching objects with timed expirey and LRU eviction.

Examples:

// Items can expire
var cache = makeCache();
cache.get('a'); // => undefined
cache.set('a', 1, {expireIn:1000});
cache.get('a'); // => 1
setTimeout(function(){
  cache.get('a'); // => undefined
}, 1100);

// Caches can be limited in size
// Least-recently-used items will evict automatically
var smallCache = makeCache({limit:2});
smallCache.set('a', 1);
smallCache.get('a'); // => 1
smallCache.set('b', 2);
smallCache.set('c', 3);
smallCache.get('a'); // => undefined

About

A library for creating generic cache objects

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published