Mastodon Feed: Post

Mastodon Feed

isagalaev ("Ivan Sagalaev :flag_wbw:") wrote:

Looking for a #Python library that would cache the most fresh responses of HTTP requests and only return cached ones in case of connection or server errors.

requests-cache doesn't do the trick: it either returns stale responses or crashes on connection errors.

Doesn't have to be HTTP-specific, really. Think of it as a general memoization with failover. But lru_cache from stdlib also doesn't work as it prefers the cached value over the available fresh one.

Last chance before I write my own!