Add a ttl method to support the refreshThreshold property of node-cache-manager for background refreshing. This would essentially allow a stale-while-revalidate pattern (not exactly SWR - it wouldn't revalidate every time) while using node-cache-manager-fs-hash.
For refreshThreshold to work with node-cache-manager it needs "the caching store to provide the ttl method.". I guess this is a similar request to https://github.com/isaacs/node-lru-cache/issues/143 (for a bit more background context).
I think this would be easy enough to implement - the expireTime property stored in each JSON file could easily be used to calculate the ttl of the key. And it could still await the lock to avoid conflicts and support cluster. In fact, it would probably be very similar to the current get method, but would return the ttl rather than data.val.
Add a
ttl
method to support therefreshThreshold
property of node-cache-manager for background refreshing. This would essentially allow a stale-while-revalidate pattern (not exactly SWR - it wouldn't revalidate every time) while using node-cache-manager-fs-hash.For
refreshThreshold
to work with node-cache-manager it needs "the caching store to provide thettl
method.". I guess this is a similar request to https://github.com/isaacs/node-lru-cache/issues/143 (for a bit more background context).I think this would be easy enough to implement - the
expireTime
property stored in each JSON file could easily be used to calculate the ttl of the key. And it could stillawait
the lock to avoid conflicts and supportcluster
. In fact, it would probably be very similar to the currentget
method, but would return the ttl rather thandata.val
.Happy to have a go at a Pull Request!