isaacs / node-lru-cache

A fast cache that automatically deletes the least recently used items
http://isaacs.github.io/node-lru-cache/
ISC License
5.38k stars 353 forks source link

v7: ttl #189

Closed isaacs closed 2 years ago

isaacs commented 2 years ago

Add options.ttl, which will make the cache throw out items that are older than the specified TTL in ms.

Use performance.now() if available, fall back to Date.now().

Expired items are not preemptively removed, and they still contribute to the LRU count until removed. They're just deleted on get() if they're expired, and not returned unless allowStale: true is set on the cache.

Date updated on get if updateAgeOnGet:true in cache options.