i’m a coroutine newbie and i’m stuck integrating c...
# coroutines
n
i’m a coroutine newbie and i’m stuck integrating co-routines and
CompletionStage
overall, my goal is to check whether i’ve an entity in the cache and if it’s not, go to the database the cache-checking returns a
CompletionStage
and the database repo is a suspending function how can i combine the two? the best i can do is:
Copy code
val person = cache.getAsync(id).await()
return if (person == null) repository.findById(id)
else person
and obviously, it’s not the right way to do it i don’t find the correct operator help greatly appreciated 🙂
j
Seems fine. I'd just clean up the Kotlin.
Copy code
return cache.getAsync(id).await() ?: repository.findById(id)
😀 2
👍 2
n
thanks 🙂