The cache engine is currently setup to use mongodb as the cache store, this will likely become more flexible in the future.
amna.cache( ... any number of key arguments ... ).read([maxage,] function (err, record) {
console.log('Got cache record:', record.key, record.value);
});
Example:
amna.cache('california', 'population').read('1w', function (err, record) {
if (err) throw err;
if (record) {
console.log('Got the population of CA from cache:', record.value);
}
else {
console.log('Cache either not set, or is older than 1 week, cannot be trusted.');
}
});
amna.cache( ... any number of key arguments ... ).save(value, function (err, record) {
console.log('Saved cache record:', record.key, record.value);
});
Example:
amna.cache('california', 'population').set(38.33e6, function (err, record) {
if (err) throw err;
console.log('Saved CA population to cache:', record.value);
});