- What version of Ehcache you are currently using;
- Paste the configuration for the Cache/CacheManager you have an issue with;
- Add any name and version of other library or framework you use Ehcache with (e.g. Hibernate);
- Providing JDK and OS versions maybe useful as well.
1. Ehcache 3.1
2. Xml configuration -> <persistence directory="java.io.tmpdir"/>
3. Spring, javax cache
4. JDK 7, Ubuntu 14
In Ehcache 2.x you could set the disk directory using <diskStore path="java.io.tmpdir"/> to the temp directory. How can this be done with Ehcache 3.x via xml ? The persistence xml element only allows a directory to be used.
Does this need to be done via Java configuration definition ? On the Ehcache getting started page it suggests using a CacheManagerBuilder to set the persistence directory but as i am creating a javax.cache.CacheManager I have not found a way to set this value.
CacheManagerBuilder.newCacheManagerBuilder()
.with(CacheManagerBuilder.persistence(getStoragePath() + File.separator + "myData")
Currently I am using a bit of the spring boot code to initialize Ehcache, see below:
String providerName = "org.ehcache.jsr107.EhcacheCachingProvider";
CachingProvider cachingProvider = Caching.getCachingProvider(providerName);
Resource configLocation = context.getResource("classpath:ehcache.xml");
javax.cache.CacheManager cacheManager = cachingProvider.getCacheManager(configLocation.getURI(),
cachingProvider.getDefaultClassLoader(),
createCacheManagerProperties(configLocation))
private Properties createCacheManagerProperties(Resource configLocation)
throws IOException {
Properties properties = new Properties();
properties.setProperty("hazelcast.config.location", configLocation.getURI()
.toString());
return properties;
}
Can this be set by property on the javax.cache.CacheManager or by another way ?
Thanks in adance,
Niall