python fallback object caching for an unreliable network

21 Views Asked by At

I'm looking at implementing a simple webhook proxy and have just been getting excited about lru_cache to prevent overloading back end APIs and improving performance.

However what about a situation where a cached object times out but the function that then executes fails to get the fresh data? Is there any "proper" approach to return the expired data instead?

Seeing how lru_cache is totally agnostic of what the function it's catching does, I presume, and so it has no place in this algorithm. Maybe there's a worthwhile way to use it though, if I've made sense.

0

There are 0 best solutions below