<ehcache><!--磁盘存储配置:用来指定缓存在磁盘上的存储位置。可以使用JavaVM环境变量(user.home, user.dir, java.io.tmpdir)--><diskStore path = "/var/apps/cache/" /><!--指定CacheManagerEventListenerFactory,这个对象在缓存添加的时候会得到相应的通知CacheManagerEventListenerFactory的属性*class - CacheManagerEventListenerFactory的一个实现类*properties - CacheManagerEventListenerFactory的属性值,以逗号(,)分割多个属性如果没有实现类被指定,则系统不创建CacheManager的监听器,没有默认值--><cacheManagerEventListenerFactory class="" properties="" /><!--在进行分布式缓存的应用时候需要指定CacheManagerPeerProviderFactory,用来生成CacheManagerPeerProvider的实例,以便和集群中的其他CacheManager通信。*class -CacheManagerPeerProviderFactory的一个实现类*properties - CacheManagerPeerProviderFactory的属性值,以逗号(,)分割多个属性Ehcache内建了2种基于RMI分布系统的通信策略:*automatic - 使用多播组。在一个节点加入或者推出集群的时候自动感应*manual - 硬编码方式目前的awf中不考虑分布缓存--><cacheManagerPeerListenerFactory class="" properties="" /><!--缓存配置。以下属性是必须的:name - cache的标识符,在一个CacheManager中必须唯一maxElementsInMemory - 在内存中缓存的element的最大数目maxElementsOnDisk - 在磁盘上缓存的element的最大数目eternal - 设定缓存的elements是否有有效期。如果为true,timeouts属性被忽略overflowToDisk - 设定当内存缓存溢出的时候是否将过期的element缓存到磁盘上以下属性是可选的:timeToIdleSeconds - 缓存element在过期前的空闲时间。默认为0,表示可空闲无限时间. (如果指定了这个时间,是否在被hit的前超过了这个时间就会被remove?在内存缓存数目超限之前不会被remove)timeToLiveSeconds - 缓存element的有效生命期。这个类似于timeouts,默认为0,不过期 (是否通常情况下应该大于等于timeToIdleSeconds,小于会如何?idle时间也会减小和这个数值一样)diskPersistent - 在VM重启的时候是否持久化磁盘缓存,默认是false。 (测试一下true的情况?重载vm的时候会从磁盘进行序列化到对象)diskExpiryThreadIntervalSeconds - 磁盘缓存的清理线程运行间隔,默认是120秒. (测试一下0的时候会如何)memoryStoreEvictionPolicy - 当内存缓存达到最大,有新的element加入的时候, 移除缓存中element的策略。默认是LRU,可选的有LFU和FIFO可对缓存中的element配置诸如监听器和加载器。Ehcahe内建了一些*cacheEventListenerFactory - 监听缓存中element的put, remove, update和expire事件*bootstrapCacheLoaderFactory - 启动时加载缓存的element每个用来做分布式缓存都必须设定element的事件监听器,用来在各个CacheManager节点复制消息。Ehcache内建了基于RMI的实现 - RMICacheReplicatorFactory <cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" properties="replicateAsynchronouly=true, replicatePuts=true, replicateUpdates=true, replicateUpdateViaCopy=true, replicateRemovals=true" />--><cache .... /><!--默认的Cache配置。用来实现CacheManager.add(String cacheName)创建的缓存--><defaultCache maxElementsInMemory="10000" eternal="false" timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true" maxElementsOnDisk="1000000" diskPersistent="false" diskExpiryThreadIntervalSeconds="120" memoryStoreEvictionPolicy="LRU" /></ehcache>