Skip to content

Asynchronous cache key generation#22

Merged
Nottezz merged 3 commits intomainfrom
asynchronous-cache-key-generation
Oct 1, 2025
Merged

Asynchronous cache key generation#22
Nottezz merged 3 commits intomainfrom
asynchronous-cache-key-generation

Conversation

@Nottezz
Copy link
Collaborator

@Nottezz Nottezz commented Sep 26, 2025

close #20

@Nottezz Nottezz requested a review from chud0 September 26, 2025 07:16
@Nottezz Nottezz self-assigned this Sep 26, 2025
import re
from hashlib import blake2b
from typing import Optional
from inspect import iscoroutinefunction
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

там же в старлетт есть is_async_callable оно в приватном _utils, но можно дернуть из использующего модуля, типа from starlette.routing import is_async_callable это хак, надежнее форкнуть метод себе с указанием откуда взяли

from fastapi import params
from starlette.requests import Request

KeyFunc = Union[
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лучше так и назови SyncOrAsync если что потом переиспользовать можно будет, что то с названием типа KeyFunc врядли

description="Cache lifetime in seconds. If None, caching is disabled.",
)
key_func: Callable[[Request], str] | None = Field(
key_func: Callable[[Request], str] | Callable[
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SyncOrAsync | None

@Nottezz Nottezz force-pushed the asynchronous-cache-key-generation branch from dc2dccd to ede846e Compare October 1, 2025 09:22
@Nottezz Nottezz merged commit f35c983 into main Oct 1, 2025
3 checks passed
@Nottezz Nottezz deleted the asynchronous-cache-key-generation branch October 1, 2025 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Support for asynchronous methods for cache key generation

2 participants

Comments