lru cache but get supports a fill callback
lru-cache where get accepts an optional "fill" callback. A fill callback would be used to populate a value in the background before it is really expired. set also supports ttl per key.
var cache = require'halfexpired-lru';cacheset'a'1;cacheget'a'iferr == 'halfexpired'requesturliferr// if i set it halfexpired will hit next in half the remaining time.cachesetkeyvalueremaining;console.log'that flakey api failed again! good thing my value is not completely expired ;)';else cachesetkeyvaluettl;;