ehCache会查找是否有同名的缓存,有的话校验不通过
@Bean(name = "ehcacheManager")
public CacheManager ehCacheManagerFactoryBean() {
CacheManager cacheManager;
try {
cacheManager = CacheManager.create(ResourceUtils.getURL("classpath:ehcache.xml"));
} catch (IOException e) {
throw new RuntimeException("initialize cacheManager failed");
}
return cacheManager;
}
private void assertNoCacheManagerExistsWithSameName(Configuration configuration)
-
diskStore:当内存缓存中对象数量超过maxElementsInMemory时,将缓存对象写到磁盘缓存中(需对象实现序列化接口)。
-
diskStore path:用来配置磁盘缓存使用的物理路径,Ehcache磁盘缓存使用的文件后缀名是.data和.index。
-
name:缓存名称,cache的唯一标识(ehcache会把这个cache放到HashMap里)。
-
maxElementsOnDisk:磁盘缓存中最多可以存放的元素数量,0表示无穷大。
- maxElementsInMemory:内存缓存中最多可以存放的元素数量,若放入Cache中的元素超过这个数值,则有以下两种情况。
- 1)若overflowToDisk=true,则会将Cache中多出的元素放入磁盘文件中。
- 2)若overflowToDisk=