nfrankel
10/29/2020, 8:23 PMCompletionStage
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:
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 🙂jw
10/29/2020, 8:30 PMreturn cache.getAsync(id).await() ?: repository.findById(id)
nfrankel
10/29/2020, 8:37 PM