passthrough for any type of backend exception

This commit is contained in:
hackjammer
2023-01-13 23:53:02 +00:00
parent 7a89f28b54
commit ab26fad604
2 changed files with 8 additions and 3 deletions

View File

@@ -2,6 +2,11 @@
## 0.2
### 0.2.1
- Fix picklecoder
- Fix connection failure transparency
- Add Cache-Control and ETag on first response
### 0.2.0
- Make `request` and `response` optional.

View File

@@ -125,7 +125,7 @@ def cache(
)
try:
ttl, ret = await backend.get_with_ttl(cache_key)
except ConnectionError:
except Exception:
ttl, ret = 0, None
if not request:
if ret is not None:
@@ -133,7 +133,7 @@ def cache(
ret = await ensure_async_func(*args, **kwargs)
try:
await backend.set(cache_key, coder.encode(ret), expire)
except ConnectionError:
except Exception:
pass
return ret
@@ -156,7 +156,7 @@ def cache(
try:
await backend.set(cache_key, encoded_ret, expire)
except ConnectionError:
except Exception:
pass
response.headers["Cache-Control"] = f"max-age={expire}"