%PDF- %PDF-
| Direktori : /proc/self/root/data/old/usr/lib/node_modules/hexo/lib/plugins/helper/ |
| Current File : //proc/self/root/data/old/usr/lib/node_modules/hexo/lib/plugins/helper/fragment_cache.js |
'use strict';
const { Cache } = require('hexo-util');
module.exports = ctx => {
const cache = new Cache();
// reset cache for watch mode
ctx.on('generateBefore', () => { cache.flush(); });
return function fragmentCache(id, fn) {
if (this.cache) return cache.apply(id, fn);
const result = fn();
cache.set(id, result);
return result;
};
};