Skip to content

Can't Cache List of serialized data #72

@Exganza

Description

@Exganza

Hi
thank you for this great module, i just have an issue that i cant cache a list of serialized dict data, i am using tortoise ORM with Pydantic Model .. my query be like
`

@app.get("/forcasts")
@cache(expire=120)
async def forcasts():
     today = datetime.today().strftime("%Y-%m-%d")
     return await Forcast_pydantic.from_queryset(Forcast.filter(date=today))

`

and i get this :
INFO:fastapi_redis_cache.client: 12/12/2022 07:13:18 PM | FAILED_TO_CACHE_KEY: Object of type <class 'list'> is not JSON-serializable: key=myapi-cache:main.forcasts()

my response that not coached correctly
[ { "id": 1, "date": "2022-12-12", "company_ar": "الرياض", "company_en": "RIBL", "code": 1010, "market_cap": 931500, "negative_positive": "negative", "duration": 5, "profit": null, "capital_protection": "-10.2601156069375" }, { "id": 2, "date": "2022-12-12", "company_ar": "الجزيرة", "company_en": "BJAZ", "code": 1020, "market_cap": 15957, "negative_positive": "negative", "duration": 7, "profit": null, "capital_protection": "-15.9395248380128" }]

can you help me with that ?
Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions