【发布时间】:2018-09-17 19:11:56
【问题描述】:
我有 2 种方法来查找客户记录(代码如下),customerGuid 和 customerId 是 Customer 对象中的 2 个不同字段。
假设我通过 customerId 查找客户一次,有没有办法让我直接从缓存中通过 guid 查找客户而不查询后端,假设这两种方法的返回类型都是客户。
public class CustomerLookup {
@Cacheable("customerCache")
public Customer getCustomerByGuid(final String customerGuid) {
// some implementation here...
}
@Cacheable("customerCache")
public Customer getCustomerByCustId(final String customerId) {
// some implementation here...
}
}
【问题讨论】:
标签: spring spring-cache