Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions lib/ceych.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,24 @@ class Ceych {
return this.cache.drop(cacheKey);
}

/**
* Manually refresh the cache entry for the given function and args combination. The function passed should be the unwrapped, initial function.
* @param {*} func
* @param {*} opts
* @param {...any} args
* @returns
*/
async refresh(func, opts, ...args) {
const cacheKey = createCacheKey(opts.func, args, opts.suffix);
const newValue = await func(...args);

if (this.stats) {
this.stats.increment('ceych.refresh');
}

return this.cache.set(cacheKey, newValue, opts.ttl ?? this.defaultTTL * 1000);
}

/**
* Disables the use of the cache. This can be useful if you want to toggle usage of the cache for operational purposes - e.g. for operational purposes, or unit tests.
*/
Expand Down
Loading