-
I am designing a service that uses a cached configuration, backed by Redis. The cache is "dummy" in the sense that it needs to be populated by the caller (this crate is an example). The following should take place during the execution of an existing task:
I have already understood (thanks to @Darksonn ) that those kinds of action should be performed by using My question is: Is it a good practice to combine I/O blocking tasks with non-blocking tasks and will Tokio do the right thing here? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
To be clear, a Redis read operation is not necessarily considered blocking. This would only be the case if you used a library that did not use async IO for talking to the Redis server. Or in the words of my blog post on blocking, it would only be blocking if it performs the IO without an await. I recommend you just make sure to use async IO, because then you will not need |
Beta Was this translation helpful? Give feedback.
To be clear, a Redis read operation is not necessarily considered blocking. This would only be the case if you used a library that did not use async IO for talking to the Redis server. Or in the words of my blog post on blocking, it would only be blocking if it performs the IO without an await.
I recommend you just make sure to use async IO, because then you will not need
spawn_blocking
.