Skip to content

Cache doesnt doesnt "discriminate" between args #475

@TC-CPHI

Description

@TC-CPHI

Hello,

Im trying to implement an in memory cache which looks at the following function. The goal is to have a cache for the same types of fromdate and todate queries that are called with the function. Yet when implementing an in memory cache as follows it always returns the same query results despite the args of the function changing to new fromdate and todate's. I've tried with custom key builders and various approaches but it seems that the cache itself is flawed?

@asynccontextmanager
async def lifespan(app: FastAPI):
    FastAPICache.init(InMemoryBackend())
    yield

app = FastAPI(lifespan=lifespan)


@app.get("/InitInt")
@cache(expire=3600)
async def InitializeInternal(api_key_fetch: str = Depends(header_scheme), fromdate : Annotated[str, Header()] = None, todate : Annotated[str, Header()] = None, offset : Annotated[int, Header()] = None):

#SOME SQL CODE

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions