https://kotlinlang.org logo
#coroutines
Title
# coroutines
r

rrva

01/07/2020, 6:51 PM
Wrote a redis client using coroutines, feedback welcome! https://github.com/rrva/coredis
👍 2
l

Luis Munoz

01/07/2020, 9:04 PM
I see you are using ktor, is the ktor socket non blocking?
also are there major benefits to using coroutines verses threads other than how the code looks? I ask because I think redis is single threaded so having many async connections might not do much as far as I can tell
r

rrva

01/07/2020, 9:14 PM
I haven’t benchmarked this in any way comparing how a threaded client would perform comparing to this or not. The point is that the redis client functions are suspendable, allowing you to use them in other contexts where you want to use coroutines. Redis is probably mostly waiting for network I/O both on the client and server side.
l

Luis Munoz

01/07/2020, 9:29 PM
Description says Redis client based on non-blocking I/O with Kotlin coroutines
but that really depends on if ktor is non blocking
you open x connections but all those take a thread that is blocking while the connection is being used right?
r

rrva

01/07/2020, 9:56 PM
no, it uses java.nio.channels.SocketChannel in non-blocking mode
47 Views