【发布时间】:2019-02-09 19:11:11
【问题描述】:
考虑代码示例:
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;
import java.time.Duration;
import static com.google.common.collect.ImmutableMap.of;
@Component
public class Scratch {
@Autowired
private WebClient webClient;
public Mono<MyClass> getMyClass(Long id) {
return webClient.get()
.uri("{id}", of("id", id))
.retrieve()
.bodyToMono(MyClass.class)
.cache(Duration.ofHours(1));
}
}
规范tells:
将保留无限的历史记录,但应用每个项目的到期超时
什么是item,什么是缓存?
- 整个 http 调用被缓存。例如。如果我用
id = 1调用方法链.get().uri(),任何后续调用都会被缓存?或 - 仅缓存
Mono<MyClass>。例如。对Mono.map的任何后续调用都将使用缓存值?
在这两种情况下,什么被视为项目?
【问题讨论】:
标签: java spring spring-webflux project-reactor