mirror of
https://github.com/long2ice/fastapi-cache.git
synced 2026-03-25 04:57:54 +00:00
passthrough for any type of backend exception
This commit is contained in:
@@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
## 0.2
|
## 0.2
|
||||||
|
|
||||||
|
### 0.2.1
|
||||||
|
- Fix picklecoder
|
||||||
|
- Fix connection failure transparency
|
||||||
|
- Add Cache-Control and ETag on first response
|
||||||
|
|
||||||
### 0.2.0
|
### 0.2.0
|
||||||
|
|
||||||
- Make `request` and `response` optional.
|
- Make `request` and `response` optional.
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ def cache(
|
|||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
ttl, ret = await backend.get_with_ttl(cache_key)
|
ttl, ret = await backend.get_with_ttl(cache_key)
|
||||||
except ConnectionError:
|
except Exception:
|
||||||
ttl, ret = 0, None
|
ttl, ret = 0, None
|
||||||
if not request:
|
if not request:
|
||||||
if ret is not None:
|
if ret is not None:
|
||||||
@@ -133,7 +133,7 @@ def cache(
|
|||||||
ret = await ensure_async_func(*args, **kwargs)
|
ret = await ensure_async_func(*args, **kwargs)
|
||||||
try:
|
try:
|
||||||
await backend.set(cache_key, coder.encode(ret), expire)
|
await backend.set(cache_key, coder.encode(ret), expire)
|
||||||
except ConnectionError:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
@@ -156,7 +156,7 @@ def cache(
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
await backend.set(cache_key, encoded_ret, expire)
|
await backend.set(cache_key, encoded_ret, expire)
|
||||||
except ConnectionError:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
response.headers["Cache-Control"] = f"max-age={expire}"
|
response.headers["Cache-Control"] = f"max-age={expire}"
|
||||||
|
|||||||
Reference in New Issue
Block a user