mirror of
https://github.com/long2ice/fastapi-cache.git
synced 2026-03-25 04:57:54 +00:00
Add default config when init
update JsonEncoder
This commit is contained in:
19
fastapi_cache/key_builder.py
Normal file
19
fastapi_cache/key_builder.py
Normal file
@@ -0,0 +1,19 @@
|
||||
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
|
||||
Reference in New Issue
Block a user