How to use the hexo-util.Cache function in hexo-util

To help you get started, we’ve selected a few hexo-util examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hexojs / hexo / lib / plugins / helper / fragment_cache.js View on Github external
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;
  };
};
github hexojs / hexo / lib / hexo / locals.js View on Github external
constructor() {
    this.cache = new Cache();
    this.getters = {};
  }