function decorators for caching

Cache Advice

by Matthew Lyon

A node.js module for caching the results of functions that take callbacks. The caching mechanism is pluggable, by default will use [lru-cache][]

var cacher = require('cache-advice')()
  , reader = cacher.get(fs.readFile)

  reader('', 'utf8')
  // will pull the result from fs.readFile, store in cache
  // by default uses the first argument as the cache key
  }, 1000);

  reader('', 'utf8')
  // will check the cache first, if found will serve from that
  // fs.readFile will not get called
  }, 2000);