事件监听器可以监听到,缓存元素创建、移除、更新、过期等。
EHCache版本: ehcache-2.9.0
实例代码:
maxEntriesLocalHeap="10000"
eternal="false"
timeToIdleSeconds="60"
timeToLiveSeconds="60"
maxEntriesLocalDisk="10000000"
diskExpiryThreadIntervalSeconds="30"
memoryStoreEvictionPolicy="LRU">
class="com.what21.ehcache.event.MyCacheEventListenerFactory"
properties="cache=mycache" />
package com.what21.ehcache.event;
import java.util.Properties;
import net.sf.ehcache.event.CacheEventListener;
import net.sf.ehcache.event.CacheEventListenerFactory;
public class MyCacheEventListenerFactory extends CacheEventListenerFactory {
@Override
public CacheEventListener createCache