Skip to content

🔀 Merge upstream #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 35 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
c2d9308
Bump pyright from 1.1.325 to 1.1.326 (#296)
dependabot[bot] Sep 8, 2023
ddde88c
Bump ruff from 0.0.286 to 0.0.288 (#300)
dependabot[bot] Sep 12, 2023
0af7761
Bump pytest from 7.3.2 to 7.4.2 (#297)
dependabot[bot] Sep 12, 2023
e2eedac
Bump types-redis from 4.6.0.5 to 4.6.0.6 (#301)
dependabot[bot] Sep 13, 2023
3e90535
Bump ruff from 0.0.288 to 0.0.290 (#305)
dependabot[bot] Sep 18, 2023
a540ee3
Bump pyright from 1.1.326 to 1.1.327 (#304)
dependabot[bot] Sep 18, 2023
f54facf
Bump types-redis from 4.6.0.6 to 4.6.0.7 (#307)
dependabot[bot] Sep 25, 2023
6983c83
Bump pyright from 1.1.327 to 1.1.328 (#310)
dependabot[bot] Sep 27, 2023
0ce7c61
Bump pyright from 1.1.328 to 1.1.329 (#311)
dependabot[bot] Sep 28, 2023
4ba67db
Bump fastapi from 0.103.1 to 0.103.2 (#312)
dependabot[bot] Sep 29, 2023
d65b12a
Bump ruff from 0.0.290 to 0.0.292 (#313)
dependabot[bot] Oct 3, 2023
42d8685
Bump pyright from 1.1.329 to 1.1.330.post0 (#317)
dependabot[bot] Oct 9, 2023
eeef78d
Bump mypy from 1.5.1 to 1.6.0 (#318)
dependabot[bot] Oct 11, 2023
d465e82
Bump pyright from 1.1.330.post0 to 1.1.331 (#319)
dependabot[bot] Oct 12, 2023
c9d4d2a
Bump ruff from 0.0.292 to 0.1.0 (#320)
dependabot[bot] Oct 17, 2023
2747470
Bump types-aiobotocore from 2.6.0 to 2.7.0 (#321)
dependabot[bot] Oct 18, 2023
8a257f2
Bump pyright from 1.1.331 to 1.1.332 (#323)
dependabot[bot] Oct 19, 2023
0af1638
Bump ruff from 0.1.0 to 0.1.1 (#324)
dependabot[bot] Oct 20, 2023
fab700a
Bump mypy from 1.6.0 to 1.6.1 (#322)
dependabot[bot] Oct 20, 2023
a315bcf
Bump pytest from 7.4.2 to 7.4.3 (#327)
dependabot[bot] Oct 25, 2023
005bac9
Bump pyright from 1.1.332 to 1.1.333 (#328)
dependabot[bot] Oct 26, 2023
583df36
Bump actions/setup-python from 4 to 5
dependabot[bot] Dec 7, 2023
91ba6d7
Merge pull request #353 from long2ice/dependabot/github_actions/main/…
long2ice Dec 7, 2023
f203d23
Switch from on_event to lifespan asynccontextmanager
CharlesPerrotMinotHCHB May 13, 2024
865dba1
Merge pull request #426 from CharlesPerrotMinotHCHB/patch-2
long2ice May 13, 2024
6aebdcc
Bump ruff from 0.0.285 to 0.0.286 (#286)
dependabot[bot] Aug 28, 2023
6093314
Bump aiobotocore from 2.5.4 to 2.6.0 (#268)
dependabot[bot] Aug 28, 2023
24614ac
Bump mypy from 1.5.0 to 1.5.1 (#276)
dependabot[bot] Aug 28, 2023
0c572b6
Bump pyright from 1.1.324 to 1.1.325 (#288)
dependabot[bot] Aug 31, 2023
9384483
Bump fastapi from 0.101.1 to 0.103.1 (#289)
dependabot[bot] Sep 4, 2023
8f683e2
:arrow_up: Upgrade to FastAPI >0.100.0
rushilsrivastava Sep 14, 2023
404ea30
:twisted_rightwards_arrows: Merge remote-tracking branch 'upstream/ma…
rushilsrivastava Jun 19, 2024
165ad11
:rotating_light: Fix linting
rushilsrivastava Jun 19, 2024
68d5bff
:zap: Use get() instead of get_with_ttl()
hnimees Jun 19, 2024
445f55b
:twisted_rightwards_arrows: Merge branch 'master' into merge-upstream
rushilsrivastava Jun 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
run: pipx install poetry
- name: Setup Python
id: setup-python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: poetry
Expand Down Expand Up @@ -51,7 +51,7 @@ jobs:
- uses: actions/checkout@v3
- name: Install Poetry
run: pipx install poetry
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: "${{ matrix.python }}"
cache: poetry
Expand Down Expand Up @@ -83,7 +83,7 @@ jobs:
- name: Install Poetry
run: pipx install poetry
- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: poetry
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/towncrier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
run: pipx install poetry
- name: Setup Python
id: setup-python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: poetry
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ or
### Quick Start

```python
from collections.abc import AsyncIterator
from contextlib import asynccontextmanager

from fastapi import FastAPI
from starlette.requests import Request
from starlette.responses import Response
Expand All @@ -74,12 +77,11 @@ async def get_cache():
async def index():
return dict(hello="world")


@app.on_event("startup")
async def startup():
@asynccontextmanager
async def lifespan(_: FastAPI) -> AsyncIterator[None]:
redis = aioredis.from_url("redis://localhost")
FastAPICache.init(RedisBackend(redis), prefix="fastapi-cache")

yield
```

### Initialization
Expand Down
8 changes: 4 additions & 4 deletions fastapi_cache/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,13 @@ async def ensure_async_func(*args: P.args, **kwargs: P.kwargs) -> R:
assert isinstance(cache_key, str) # noqa: S101 # assertion is a type guard

try:
ttl, cached = await backend.get_with_ttl(cache_key)
cached = await backend.get(cache_key)
except Exception:
logger.warning(
f"Error retrieving cache key '{cache_key}' from backend:",
exc_info=True,
)
ttl, cached = 0, None
cached = None # noqa: F841

# Determine cache-control value
cache_control = ""
Expand Down Expand Up @@ -230,14 +230,14 @@ async def ensure_async_func(*args: P.args, **kwargs: P.kwargs) -> R:
response.headers.update(
{
"Cache-Control": cache_control,
"ETag": f"W/{hashlib.md5(to_cache.encode()).hexdigest()}",
"ETag": f"W/{hashlib.md5(to_cache.encode()).hexdigest()}", #noqa: S324
cache_status_header: "MISS",
}
)

else: # cache hit
if response:
etag = f"W/{hashlib.md5(cached.encode()).hexdigest()}"
etag = f"W/{hashlib.md5(cached.encode()).hexdigest()}" #noqa: S324
response.headers.update(
{
"Cache-Control": cache_control,
Expand Down
Loading