Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/323.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 是否可以缓存列表<;对象>;使用EhCache?_Java_Spring_Spring Boot_Caching_Ehcache - Fatal编程技术网

Java 是否可以缓存列表<;对象>;使用EhCache?

Java 是否可以缓存列表<;对象>;使用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

如何使用EHCache实现列表缓存?是否有任何额外配置或我遗漏的任何内容

ConfigurationFile.java

@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();
}
请帮忙