- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我在 grails 2.5.3 中有以下情况:
EmployeeService{
@Cacheable(value = "employees")
public List<Employee> getEmployeeList() {
return Employee.list()
}
public Employee getEmployee(long id){
return getEmployeeList().find{it.id == id}
}
}
EmployeeController{
def employeeService
def getEmployee(long id){
render employeeService.getEmployee(id) as JSON
}
}
我的问题是 - EmployeeService
中的 @Cacheable
注释方法没有将数据存储在 Redis 缓存中,我应该怎么做才能完成这种情况。
提前谢谢你。
最佳答案
缓存由spring提供。所以需要使用spring方式调用方法来应用缓存:
EmployeeService {
def grailsApplication
@Cacheable(value = "employees")
public List<Employee> getEmployeeList() {
return Employee.list()
}
public Employee getEmployee(long id){
return proxy.getEmployeeList().find {it.id == id}
}
// using springs bean proxy ensures cacheable aspects are applied
private getProxy() {
grailsApplication.mainContext.employeeService
}
}
关于caching - Grails Redis 缓存 - 间接调用 @Cacheable 注释方法 - 如何工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50932005/
我正在尝试使用 Spring Cacheable,但遇到了类转换异常 @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(cla
我就废话不多说了,大家还是直接看代码吧~ ? 1
我有这个实用方法来加载我的网络应用程序的内容 @Cacheable(value="dataStrore" ) public MarketJson retrieveMarketJson(DataRequ
与内存数据库一起使用@Cacheable是否相关? 我在内存数据库中使用 h2,只是想知道使用 @Cacheable 可以提高应用程序的性能。我的应用程序将频繁调用数据库中的静态数据 最佳答案 一般来
将 Spring 3.2 与 EhCache 2.9 一起使用。我已经注释了一个零参数方法如下: @Cacheable(value="myList", key="#result.method.name
我正在尝试将 Redis 与 Spring 的 @Cacheable 一起使用,但需要根据 Spring Boot 样式的应用程序属性有条件地打开或关闭缓存。我的第一次尝试似乎没有用。 applica
我在 Spring 3.2 中使用 @Cacheable 来缓存服务层方法的结果。服务类内部使用以下方法代码: @Cacheable("questions") public List getSecut
如何查看@Cacheable 的实现。我想了解他们如何能够获取方法参数的名称并在运行时获取其实际值。 例如: @Cacheable(cacheNames = "name", key = "#k
我正在努力在 Spring Boot 集成测试中测试 @Cacheable。这是我学习如何进行集成测试的第二天,我发现的所有示例都使用旧版本。我还看到了 assetEquals("some value
背景 项目中,使用@Cacheable进行数据缓存。发现:当redis宕机之后,@Cacheable注解的方法并未进行缓存冲突,而是直接抛出异常。而这样的异常会导致服务不可用。 原因分析 我们
我在 Spring 4.1.4 应用程序中使用最新的 Ehcache。我所拥有的是: class Contact{ int id; int revision; } @Cachea
我已经看到很多同一个问题的化身,但我想我已经尝试了所有修复 - 我的用法非常简单。 我一直在使用 Ehcache,但也没有用。因此,为了排除 Ehcache 问题并帮助指出更基本的东西,我转向了 Si
我有一个关于 Spring Security 和 Spring Caching 的问题。假设我有一个方法,并且我已经用 @PreAuthorize("condition") 和 @Cacheable(
我一般用@Cacheable在我的 spring-boot 应用程序中使用缓存配置并为每个缓存设置特定的 TTL(生存时间)。 我最近继承了一个使用 @Cacheable 的 spring boot
我想将一项服务设为可缓存。我一直在研究grails-cache plugin它看起来很有希望,但它导致了一些我不理解的行为。 考虑以下服务: class FooService { def co
我在使用多参数和分页的 @Cacheable 时遇到问题。 @Cacheable(value = "books", key = "#p0") public List findBooks(Long lo
当调用带有 @Cacheable 注释且同步标志设置为 true 的方法时,出现以下异常: java.lang.AbstractMethodError: org.springframework.cac
我已将我的应用程序升级到 Spring 3.1,并且所有 jar 都已充分更新。但是,当我尝试对其中一个 Controller 中的方法使用 @Cacheable 时,该 Controller 的所有
如何进行以下工作? public abstract class MyAbstractOne { @Cacheable(value="myCache") public MyObj
尝试使用内联刷新来实现我自己的缓存加载器。此缓存加载使用 RefreshAheadCacheFactory 如描述 http://terracotta.org/documentation/4.1/bi
我是一名优秀的程序员,十分优秀!