-
Notifications
You must be signed in to change notification settings - Fork 98
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
[discussion] Support Async stores #98
Comments
Let me start. Some points to keep in mind:
My suggestion is to:
We should be able to know if we need to use the sync or async impls in compile-time, because of that, we have the point 4 in my suggestion. I would like to make it smarter, like if the function is async, then use the async version of store, otherwise use the sync. But first I don't know how to do it and second, I'm not sure the outcome will be good enough! |
Hi @omid ! Thanks for starting the discussion On your points:
I don't think we should since not everyone needs async support and disabling it cuts down compile time since there's a couple dependencies that get removed. On that topic though, I think some of the optional dependencies could be cleaned up here Line 19 in cd10eac
async-mutex async-rwlock deps should be moved to be only included when the async flag is enabled
I don't remember exactly, but I believe I did it with only these two methods because of the annoyances of dealing with async blocks and incorporating them with the macros, and this simplified the problem in some way (can't remember exactly - maybe it was just to make macro integration easier in general). Either way - I think it's a convenient API worth keeping since the cache type has the opportunity to handle the get/set more efficiently than a user calling get and set separately. This also has to do with the next point because all current caches implement
I think I see where you're coming from here based on your initial 3 points, but I think you may be a little off here. Lets go back to your initial points quick:
Sort of... in our current state, all the cache stores are really not async since there's no IO or anything about them that needs to be "async". What makes them usable interchangeably between It might make sense to introduce two new traits that cover this, where the actual implementation differs between sync and async. Maybe something along the lines of
We already handle automatically generating sync vs async code based on the "asyncness" of the function that we're annotating. So it wouldn't hurt to add this as an optional flag for you to do things like force an async functions to access its cache synchronously, but I don't think it's something people would want to use. To summarize my thoughts on this:
|
Thanks.
That's one of the reasons that I'm saying we need to remove
Yes, something similar is exactly what I also think of. I had some other naming in my mind, like:
(We can merge number 3, 4 and 5, in different circumstances. But in that case, it may be better if we remove the Some stores may need to impl (And in case we remove the helpers, it will be clearer and will simplify things a lot :D)
I know about What I'm saying is that the following code shouldn't call the async version of the cache.
ps: Your last question is kinda out of scope of this topic, |
Thanks @jaemk for version 0.31 ❤️ |
Currently, all stores we have are sync, since they all are in-memory.
To support async-able stores, like filesystem, Redis and other remote stores.
Now let's discuss what should we do for that?
The text was updated successfully, but these errors were encountered: