Java 是否可以缓存列表<;对象>;使用EhCache?
如何使用EHCache实现列表缓存?是否有任何额外配置或我遗漏的任何内容 ConfigurationFile.javaJava 是否可以缓存列表<;对象>;使用EhCache?,java,spring,spring-boot,caching,ehcache,Java,Spring,Spring Boot,Caching,Ehcache,如何使用EHCache实现列表缓存?是否有任何额外配置或我遗漏的任何内容 ConfigurationFile.java @Configuration @EnableCaching public class CachingConfig extends CachingConfigurerSupport { @Bean @Override public CacheManager cacheManager() { return new EhCacheCache
@Configuration
@EnableCaching
public class CachingConfig extends CachingConfigurerSupport {
@Bean
@Override
public CacheManager cacheManager() {
return new EhCacheCacheManager(getEHcacheManager());
}
@Bean
public net.sf.ehcache.CacheManager getEHcacheManager() {
final CacheConfiguration tobpCache = new CacheConfiguration();
tobpCache.setLogging(true);
tobpCache.setName("tobpCache");
tobpCache.setMemoryStoreEvictionPolicy("LRU");
tobpCache.setMaxEntriesLocalHeap(2000);
final net.sf.ehcache.config.Configuration configuration = new net.sf.ehcache.config.Configuration();
configuration.addCache(tobpCache);
return net.sf.ehcache.CacheManager.newInstance(configuration);
}
}
ServiceImpl.java
@Override
@Cacheable(cacheNames = "tokens", value = "tobpCache")
public List<Token> findAll() {
log.info(ApplicationConstants.METHOD_CALLED_LABEL);
return (List<Token>) getDaoFactory().getTokenDao().findAll();
}
@覆盖
@可缓存(cacheNames=“tokens”,value=“tobpCache”)
公共列表findAll(){
log.info(ApplicationConstants.METHOD_称为标签);
返回(列表)getDaoFactory().getTokenDao().findAll();
}
请帮忙