25 lines
540 B
JavaScript
25 lines
540 B
JavaScript
import Debug from 'debug';
|
|
const debug = Debug('twtkpr:memoryCache');
|
|
/**
|
|
*
|
|
* @param req
|
|
* @param res
|
|
* @param next
|
|
* @param cache
|
|
* @param reloadCache
|
|
* @returns
|
|
*/
|
|
export default async function memoryCache(req, res, next, cache, reloadCache) {
|
|
if (cache.keys().length && !['DELETE', 'POST', 'PUT'].includes(req.method)) {
|
|
next();
|
|
return;
|
|
}
|
|
reloadCache()
|
|
.then(() => {
|
|
next();
|
|
})
|
|
.catch((err) => {
|
|
console.error(err);
|
|
});
|
|
}
|
|
//# sourceMappingURL=memoryCache.js.map
|