具有暂停功能的可缓存功能

问题描述 投票:0回答:1

我正在尝试编写可缓存的暂挂函数,我认为它无法正常工作。我正在:

@Cacheable("product-image")
suspend fun getProductImage(productId: String): String {
    return productRetriever.getProductImage(productId).awaitSingle()
}

它似乎没有缓存信息。类已正确接线。以下代码似乎有效,但它产生Mono而不是String

@Cacheable("product-image")
suspend fun getProductImage(productId: String): Mono<String> {
    return productRetriever.getProductImage(productId).cache()
}
spring ehcache kotlin-coroutines
1个回答
0
投票

我正在经历这个。似乎@Cacheable无法缓存暂挂函数。当我将函数更改为常规函数时,它起作用了Mono

© www.soinside.com 2019 - 2024. All rights reserved.