サイトメニュー
|
|
CacheManager manager = CacheManager.getInstance();
URL url = getClass().getResource("/package/anothername.xml");
CacheManager manager = CacheManager.create(url);
CacheManager manager = CacheManager.create("src/config/ehcache.xml");
manager.shutdown();
Cache cache = manager.getCache("sampleCache1");
// Cache(String name, int maximumSize, boolean overflowToDisk,
// boolean eternal, long timeToLiveSeconds, long timeToIdleSeconds,
// boolean diskPersistent, long diskExpiryThreadIntervalSeconds)
Cache testCache = new Cache("test", 1000, true, false, 500, 200, false, 120);
manager.addCache(cache);
cache.removeAll();
Element element = new Element("key1", "value1");
cache.put(element);
Element element = cache.get("key1");
cache.remove("key1");
<ehcache>
<diskStore path="java.io.tmpdir"/>
<defaultCache
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
overflowToDisk="true"
/>
<cache name="my.package.Class"
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="300"
timeToLiveSeconds="600"
overflowToDisk="true"
/>
</ehcache> |