-
Notifications
You must be signed in to change notification settings - Fork 28
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
Performance issue #271
Comments
Hello, I thought it is normal that cashews is so slow compare to functools.cache (LRU by the way), because there are a big difference between it. Functools cache don't have:
The main goal of Cashews is to provide a better interface for using cache in a project, and the focus is NOT on in-memory cache, but on Redis. FastAPI is just the name of the framework, it is based on Starlette, and Starlette is probably faster. So cashews as a web-framework agnostic cache framework wants to be fast but in comparison with frameworks offering similar functionality. For better performance I can suggest :
|
JFYI I tried to dig deeper into why the performance is so bad. I found a few issues that I quickly fixed (here) and a few more that could be fixed but with a lot of changes. I plan to improve the performance in the next major version |
Comparing functools.cache and cashews in mem cache:
500 ns
to return (sync function)75000 ns
to return (async function)for reference I used that for Cashews
and that for functools (no LRU)
My goal was mostly to allow to do asyncio.gather(f1, f2...)
Do you know if timings can be improved ? It is not that important to me for now, as ns and us dont really matter in my kind of apps.
But I see you mention FastAPI, which definitely should support fastest possible caching.
I assume the slower timings is mostly implied by the expiration algorithms right?
The text was updated successfully, but these errors were encountered: