0.0.1 • Published 11 years ago
node-quickcache v0.0.1
node-quickcache
A full-featured caching module for node.js
Usage
var cache = require('quickcache');
cache.useCounter();
cache.set('mike', 20);
console.log(cache.get('mike'));Example
Trigger
Setup trigger for an entry.
var cache = require('quickcache');
cache.trigger('mike', 'value == 18',
function() {
console.log('>> triggered!');
});
cache.set('mike', 10);
cache.set('mike', 18); // will be triggeredCounter
See how many times the entry has been called.
var cache = require('quickcache');
cache.useCounter();
cache.set('mike', 20);
for (var i = 0; i < 500; i++) cache.get('mike');
console.log(cache.getCount('mike')); // will be 500Functions
set(key, value)- set entryget(key)- get entrygetCount(key)- returns the number of the entry has been calleddelete(key)- delete entryclear()- clean up all entriesincrby(key, incr)- increments the number stored at key by incrementttl(key, time, timeoutCallback)- set time-to-live for an entryuseCounter()enable/disable counterisEmptyCache(key)- checks whether the cache is emptyisValidKey(key)- checks whether the entry existsisValidTrigger(key)- checks whether the entry has a triggerkeys()- returns an array of the entry keys in cachesize()- returns the number of entries in cachetrigger(key, conditions, callbackFunction)adds a trigger for an entrygetTriggerCount(key)- returns the number of the trigger has been usedremoveTrigger(key)- remove trigger from an entry
0.0.1
11 years ago