cachou
Simple and fast cache module based on redis.
Install
npm install cachou
Usage
var cachou = ; var cache = ; cache;cache;cache;
cachou(options) / new cachou.Cache(options)
Create a new custom cache.
var cache = ;
or
var cache = ttl: 20 ;
There are several options avalaible:
redis
Type: Object
or Function
If you specify an object, the properties will be used to call redis.createClient
method. The redis module used
will be the Redis module installed. This project doesn't have node_redis module as dependency.
var cache =
If you specify a function, it will be called to create redis client.
var redis = ; var cache = { var client = redis; client; // Choose a custom database. return client;}
ttl
Type: Number
Specify the time after the cache will expire in milliseconds.
var cache = ;
prefix
Type: String
Specify the prefix of the keys.
var cache = ;
cache.get(key, callback)
Fetch a data from the cache.
cache;
cache.set(key, data, callback)
Put a data in the cache.
cache;
cache.del(key, callback)
Remove a key from the cache.
cache;
cache.delAll(pattern, callback)
Delete key using a glob matching pattern.
cache; // Will delete all keys starting with "my:"
License
MIT