【发布时间】:2018-11-29 13:10:35
【问题描述】:
我的用例是我想在我的服务调用者类中缓存某些请求:响应:
public class Abc{
public Response serviceCall(Request r){}
}
public class Memcached{
public Response get(Request r){}
public void put(Request r, Response rs){}
}
我想使用 memcached 进行缓存。请求将是键,值将是响应。每当调用 serviceCall() 时,我想检查请求是否已存在于缓存中,如果存在,则从缓存中返回响应。 如果没有,则实际执行 serviceCall() 方法并将 request:response key:value 放入 memcached
春天有什么办法可以达到同样的效果。
我确实在这里查看了@Cacheable http://www.baeldung.com/spring-cache-tutorial
但我无法理解如何让 spring 使用我的“Memcached”类,更具体地说,我在哪里连接我的“Memcached”类,以便在上面的示例中它可用于“Abc”类
请您帮忙。我正在 Spring Boot 中工作,完全基于注释并寻找基于注释的解决方案
【问题讨论】:
标签: java spring spring-boot caching