Spring 具有挂起功能的可缓存

Spring 具有挂起功能的可缓存,spring,ehcache,kotlin-coroutines,Spring,Ehcache,Kotlin Coroutines,我正在尝试编写可缓存的挂起函数,我认为它不能正常工作。 我有: @Cacheable("product-image") suspend fun getProductImage(productId: String): String { return productRetriever.getProductImage(productId).awaitSingle() } 它似乎没有缓存信息。类已正确连接。 下面的代码似乎可以工作,但它生成的是Mono而不是String @Cacheable(

我正在尝试编写可缓存的挂起函数,我认为它不能正常工作。 我有:

@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()
}
@Cacheable(“产品图像”)
挂起getProductImage(productId:String):Mono{
返回productRetriever.getProductImage(productId.cache())
}