node-request-caching icon indicating copy to clipboard operation
node-request-caching copied to clipboard

Request TTL

Open ericclemmons opened this issue 12 years ago • 2 comments

What do you think about returning the remaining TTL with the cache object as well?

I need to be able to say "3 minutes old" or similar, so the user knows if they should force a refresh or not.

From what I can tell, the best way (that works across all stores) is to store the request payload with the TTL information (TTL + UNIX timestamp) so that it can be returned/calculated when retrieving from the cache:

https://github.com/matteoagosti/node-request-caching/blob/master/lib/store/redis.js#L41

ericclemmons avatar Mar 31 '13 16:03 ericclemmons

Make sense, I'll work on it as I would like to get this directly into the RequestCaching object rather than in the storage implementation or at least find a way to ensure the storage implementation doesn't need to think about the details of the cache object response.

matteoagosti avatar Apr 01 '13 12:04 matteoagosti

That makes sense for me, and would certainly be ideal from the storage standpoint :)

Let me know how you'd like me to help!

ericclemmons avatar Apr 01 '13 14:04 ericclemmons