mirror of
https://github.com/long2ice/fastapi-cache.git
synced 2026-03-24 20:47:54 +00:00
20 lines
463 B
Python
20 lines
463 B
Python
from typing import Optional
|
|
|
|
from starlette.requests import Request
|
|
from starlette.responses import Response
|
|
|
|
|
|
def default_key_builder(
|
|
func,
|
|
namespace: Optional[str] = "",
|
|
request: Request = None,
|
|
response: Response = None,
|
|
*args,
|
|
**kwargs,
|
|
):
|
|
from fastapi_cache import FastAPICache
|
|
|
|
prefix = FastAPICache.get_prefix()
|
|
cache_key = f"{prefix}:{namespace}:{func.__module__}:{func.__name__}:{args}:{kwargs}"
|
|
return cache_key
|