https://kotlinlang.org logo
Title
o

oshai

04/10/2019, 2:27 PM
Is anyone aware of a cache utility (like guava loading cache) that works with coroutines? (ie has suspending methods, not returning deferred) I found the following solutions, but none of them do that: - https://stackoverflow.com/questions/53558215/guava-loadingcache-with-kotlin-coroutines - https://github.com/epam/CoroutinesCache
s

Sam

04/10/2019, 4:39 PM
If source of Deferred is from retrofit, support for suspend is being added to retrofit https://github.com/square/retrofit/pull/2886
Otherwise, you could still wrap it under a suspend function and expose that to clients
o

oshai

04/10/2019, 6:30 PM
Its from retrofit but its couple of calls + logic. That make it hard to create a deferred out of it
s

spand

04/11/2019, 7:53 AM
We use
Caffeine
(successor to guava cache) with its
AsyncLoadingCache
that is super easy to wrap with suspending methods using the jdk coroutine adapters