0.0.1 • Published 11 years ago
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 entry
- get(key)- get entry
- getCount(key)- returns the number of the entry has been called
- delete(key)- delete entry
- clear()- clean up all entries
- incrby(key, incr)- increments the number stored at key by increment
- ttl(key, time, timeoutCallback)- set time-to-live for an entry
- useCounter()enable/disable counter
- isEmptyCache(key)- checks whether the cache is empty
- isValidKey(key)- checks whether the entry exists
- isValidTrigger(key)- checks whether the entry has a trigger
- keys()- returns an array of the entry keys in cache
- size()- returns the number of entries in cache
- trigger(key, conditions, callbackFunction)adds a trigger for an entry
- getTriggerCount(key)- returns the number of the trigger has been used
- removeTrigger(key)- remove trigger from an entry
0.0.1
11 years ago