cacheman icon indicating copy to clipboard operation
cacheman copied to clipboard

allow to pass ttl in callback of wrapped function

Open dcolens opened this issue 7 years ago • 0 comments

sometimes the lookup of a value will also yield its expiration time. It would be nice that the callback of the work function allows for a third ttl param, for example :

function work(callback) {
  callback(null, { a: 'foo' }, '10s');
}

cache.wrap('foo', work, function (err, data) {
  console.log(data); //-> {a: 'foo'}
});

am not sure how this would work for Promises?

dcolens avatar Aug 09 '18 12:08 dcolens