hapijs / catbox

Multi-strategy object caching service
Other
494 stars 72 forks source link

Information on approach to cached objects #148

Closed jsmartfo closed 8 years ago

jsmartfo commented 8 years ago

I am looking for some confirmation on how to store, update and expire data held in catbox.

We attempt a get on the cache, if the data doesn't exist we make a service call receive data and add to cache using set with a ttl, all new requests are served from cache until ttl expires, once it expires the data is automatically removed from cache and we make service call again to update.

With this approach the following issue can occur, service call fails or responds with bad data, the cache has expired and there is no longer an element in cache so now we are left in a situation without any data to serve.

How can I expire data in the cache (make it stale) but still have it served as a fallback if I fail to complete the service call to refresh - is this possible?

Thanks

hueniverse commented 8 years ago

Just use stale with generate function.

lock[bot] commented 4 years ago

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.