Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't Cache List of serialized data #72

Open
Exganza opened this issue Dec 12, 2022 · 1 comment
Open

Can't Cache List of serialized data #72

Exganza opened this issue Dec 12, 2022 · 1 comment

Comments

@Exganza
Copy link

Exganza commented Dec 12, 2022

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

@anthonymckale-6point6
Copy link

believe this pull request fixes the issue

using it locally in a forked repo to work for me

https://github.com/a-luna/fastapi-redis-cache/pull/65/files

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

No branches or pull requests

2 participants