I'm using Guava's Loading Cache
to cache the results of HTTP requests. Kotlin / KTOR provides an HTTP Client Library based on coroutines (i.e. non-blocking HTTP requests).
My problem is that the Loading Cache has no idea about suspend
ing functions. The load
function that I pass to the loading cache cannot suspend. So I am forced to do the HTTP requests inside a runBlocking
call, eliminating the benefit of non-blocking calls completely.
My question is: is there a better way? How would you implement caching of coroutine results?