Cache any data quickly and easily in Redis. Caching data is important to most applications. This hook handles various common requirements for caching data, specifically in Redis.
First ensure you have RediBox installed.
Install Schedule via npm:
npm install redibox-hook-cache --save
This hook will still work without setting any configuration options.
Within your redibox
config, we'll setup a new cache
object containing our configiration options:
true
60
cache
// Get data by key from the cache
RediBox.hooks.cache.get('cat').then(data => {
console.log('Got a cat from cache', data);
});
// Set data by key in the cache
RediBox.hooks.cache.set('cat:fluffy', 'https://pbs.twimg.com/media/CYY44mYWMAATghb.jpg:small').then(() => {
console.log('Set a fluffy cat in cache');
});
// Delete an item by key in the cache
RediBox.hooks.cache.del('cat').then(data => {
console.log('Deleted item');
});
// Delete all items in cache
RediBox.hooks.cache.clear().then(data => {
console.log('Clear all data in cache');
});
// Delete all matching wildcard items in cache
RediBox.hooks.cache.clear('cat:fluffy:*').then(data => {
console.log('Clear wildcard data from cache');
});
MIT