Abd*_*DMA 2 java spring caching spring-mvc
我必须缓存以下public方法的结果:
    @Cacheable(value = "tasks", key = "#user.username")
    public Set<MyPojo> retrieveCurrentUserTailingTasks(UserInformation user) {
        Set<MyPojo> resultSet;
        try {
            nodeInformationList = taskService.getTaskList(user);
        } catch (Exception e) {
            throw new ApiException("Error while retrieving tailing tasks", e);
        }
        return resultSet;
    }
我还在这里配置了缓存:
@Configuration
@EnableCaching(mode = AdviceMode.PROXY)
public class CacheConfig  {
@Bean
public CacheManager cacheManager() {
    final SimpleCacheManager cacheManager = new SimpleCacheManager();
    cacheManager.setCaches(Arrays.asList(new ConcurrentMapCache("tasks"),new ConcurrentMapCache("templates")));
    return cacheManager;
}
@Bean
public CacheResolver cacheResolver() {
    final SimpleCacheResolver cacheResolver = new SimpleCacheResolver(cacheManager());
    return cacheResolver;
}
}
我断言如下:
ConcurrentMapCache(2个实例),它们在堆中但是空的@CacheConfig(cacheNames = "tasks")添加在我的控制器之上Spring版本4.1.3.RELEASE Jdk 1.6
更新001:
  @RequestMapping(value = "/{kinematicId}/status/{status}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public DocumentNodeWrapper getDocumentsByKinematicByStatus(@PathVariable String kinematicId, @PathVariable String status, HttpServletRequest request) {
    UserInformation user = getUserInformation(request);
    Set<ParapheurNodeInformation> nodeInformationList =  retrieveCurrentUserTailingTasks(user);
    final List<DocumentNodeVO> documentsList = getDocumentsByKinematic(kinematicId, user, nodeInformationList);
    List<DocumentNodeVO> onlyWithGivenStatus = filterByStatus(documentsList);
    return new DocumentNodeWrapper("filesModel", onlyWithGivenStatus, user, currentkinematic);
}
谢谢
| 归档时间: | 
 | 
| 查看次数: | 3165 次 | 
| 最近记录: |