1.0.4 • Published 6 years ago

cachelee v1.0.4

Weekly downloads
3
License
ISC
Repository
github
Last release
6 years ago

Cachlee

A fast caching mechanism for NodeJS applications

Install

npm install --save cachelee

Usage

You can set some options for caching by giving it a setting object with the following possible properties:

PropertyValueDefault
limitnumeric1000
strategyLRU/LFULFU

API

cacheManager.cache(key, value) - add to cache with key and value. Note that the key could be anything (string, object etc.)
cacheManager.get(key) - get cached object by key. returns null of none existing
cacheManager.size() - get current size of the cache
cacheManager.maxSize() - get the max size set for the cache
cacheManager.setStrategy(strategy) - change the caching strategy. In this you have two possibilities: LeastRecentlyUsed (default) or LeastFrequentlyUsed. (see example below)

var cachelee = require('cachelee');

var cacheManager = new cachelee.Cache( {   limit: 500, 
                                           strategy: cachelee.Strategy.LeastRecentlyUsed
                                       });

// add to cache by cacheManager.cache(KET, VALUE);
cacheManager.cache('A',{value: 'A'});
cacheManager.cache('B',{value: 'B'});
cacheManager.cache('C',{value: 'C'});

// extract from cache by cacheManager.get(KEY);

var aObj = cacheManager.get('A')

You can also change strategy by:

cacheManager.setStrategy(cachelee.Strategy.LeastFrequentlyUsed);
1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago