EhCache配置文件

Posted on

EhCache配置文件 - 奈何桥收费站。。。 - ITeye技术网站

首页 资讯 精华 论坛 问答 博客 专栏 群组 更多 ▼

招聘 搜索

您还未登录 ! 登录 注册

奈何桥收费站。。。

EhCache配置文件 **

博客分类:

Xml代码 收藏代码

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. CacheManager配置
  4. ==========================
  5. 一个ehcache.xml 相当于一个单个的CacheManager
  6. 学习下面的说明或者ehcache构架(ehcache.xsd)怎样配置
  7. 系统资源标识在这个文件中能被具体制定,当配置被加载时,他们将会被替换。例如 multicastGroupPort=${multicastGroupPort}被环境变量的系统属性替换,或是使用如-DmulticastGroupPort=4446命令行开关指定一个系统属性。
  8. 的属性如下:
  9. /* name – CacheManager的可选名称。这个名称起初主要是用于文档记录或辨别Terracotta集群状态。对于Terracotta集群的缓存,一组CacheManager名称和cache名称唯一的鉴定了一个特定的存储于Terracotta集群存储器的缓存。
  10. /* updateCheck – 一个可选的boolean标识符,指定这个CacheManager是否通过Internet检查Ehcache的新版本。如果没有特别指明,updateCheck="true".
  11. /* monitoring – 一个可选的设置,决定CacheManager是否应该自动的用系统MBean服务器注册SampledCacheMBean。当下,这个监测。只有当使用Terracotta集群和使用Terracotta Developer Console时才有用。使用"autodetect"值,Terracotta集群的出现将被检测和监视,并通过Developer控制台激活。其他允许的值有:"on" 和 "off"。默认为"autodetect"。当使用JMX监测时,这个设置不会产生任何作用。
  12. /* dynamicConfig – 一个可选设置,能够使与这个CacheManager相关联的动态配置失活。这个设置的默认值是true-例如,动态配置是激活的。动态配置的缓存通过缓存的配置对象让他们的TTI, TTL 和maximum disk 和in-memory capacity在运行时改变。
  13. -->
  14. <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  15. xsi:noNamespaceSchemaLocation="ehcache.xsd"
  16. updateCheck="true" monitoring="autodetect"
  17. dynamicConfig="true" >
  18. <!--
  19. DiskStore configuration
  20. =======================
  21. 磁盘存储器是可选的。关闭磁盘存储路径创建,解释下面的磁盘存储器元素。
  22. 对于任何缓存,如果你已经激活了overflowToDisk或diskPersistent,就要配置磁盘存储器。
  23. 如果他未配置,并且创建了一个需要磁盘存储的缓存,将会发出一个警告并且java.io.tmpdir将会自动使用。
  24. 磁盘存储器仅有一个属性- "path"。这个路径就是.data and .index文件被创建的目录路径。
  25. 如果这个路径是下述Java系统属性之一,他将会被运行中的VM中的值替换。为了向后兼容,这些应该被特别规定,而不会被${token}替换语法封闭。
  26. 下列属性翻译:
  27. /* user.home -用户的根目录
  28. /* user.dir – 用户的当前工作目录
  29. /* java.io.tmpdir – 默认临时文件路径
  30. /* ehcache.disk.store.dir – 一个系统属性,你通常用命令行指定;
  31. 例如: java -Dehcache.disk.store.dir=/u01/myapp/diskdir ...
  32. 子目录通过如下属性指定,例如:java.io.tmpdir/one
  33. -->
  34. <!--
  35. TransactionManagerLookup configuration
  36. ======================================
  37. TransactionManagerLookup 配置
  38. 这个类被ehcache用XA激活的ehcache来查找用于应用程序中的JTA TransactionManager。如果没有指定类,那么DefaultTransactionManagerLookup将以如下顺序找到TransactionManager。
  39. /*GenericJNDI(例如:jboss,属性jndiName控制TransactionManager对象的名称来查找)
  40. /*Websphere
  41. /*Bitronix
  42. /*Atomikos
  43. 你可以提供自己的查找类实现net.sf.ehcache.transaction.manager.TransactionManagerLookup接口。
  44. <!--
  45. CacheManagerEventListener
  46. =========================
  47. 指定一个CacheManagerEventListenerFactory,当缓存被增加或从CacheManager移除时被告知。
  48. CacheManagerEventListenerFactory的属性有:
  49. /* class – 一个完全限定的工厂类名。
  50. /* properties – 逗号隔开的属性只对工厂有意义。
  51. overflowToDisk:设置元素是否能溢出磁盘,当存储器容量达到最大存储限制。
  52. 如下属性和元素是可选的。
  53. timeToIdleSeconds:
  54. Sets the time to idle for an element before it expires.
  55. 设置一个元素在过期前的空闲时间
  56. i.e. The maximum amount of time between accesses before an element expires
  57. Is only used if the element is not eternal.
  58. 换言之,最大时间数在进入之后和元素过期之前这段时间之间,只有元素在非持久化时才有用。
  59. Optional attribute. A value of 0 means that an Element can idle for infinity.
  60. 可选属性,0表示一个元素可以无限的空闲
  61. The default value is 0.
  62. 默认值是0。
  63. timeToLiveSeconds:
  64. Sets the time to live for an element before it expires.
  65. i.e. The maximum time between creation time and when an element expires.
  66. Is only used if the element is not eternal.
  67. Optional attribute. A value of 0 means that and Element can live for infinity.
  68. The default value is 0.
  69. 在元素过期之前,设置一个存留时间。换言之,最大时间在创建时间和元素过期之间。仅用于元素非持久化。可选属性。值为0表示元素可无限存留,默认值是0
  70. diskPersistent:
  71. Whether the disk store persists between restarts of the Virtual Machine.
  72. The default value is false.
  73. 磁盘存储是否在虚拟机重启后持续存在。默认只是false。
  74. diskExpiryThreadIntervalSeconds:
  75. The number of seconds between runs of the disk expiry thread. The default value
  76. is 120 seconds.
  77. 秒数在运行和磁盘终止线程之间,默认值是120秒。
  78. diskSpoolBufferSizeMB:
  79. This is the size to allocate the DiskStore for a spool buffer. Writes are made
  80. to this area and then asynchronously written to disk. The default size is 30MB.
  81. Each spool buffer is used only by its cache. If you get OutOfMemory errors consider
  82. lowering this value. To improve DiskStore performance consider increasing it. Trace level
  83. logging in the DiskStore will show if put back ups are occurring.
  84. 这是为后台打印缓冲分配在DiskStore的大小。在这一区域进行写入,并同步写入磁盘。默认值是30M。每个后台缓冲区仅由他的缓存使用,如出现OutOfMemory错误,考虑降低该值。为了提高DiskStore性能,考虑增加它。跟踪级别的DiskStore工作 将显示是否推迟出现。
  85. clearOnFlush:
  86. whether the MemoryStore should be cleared when flush() is called on the cache.
  87. By default, this is true i.e. the MemoryStore is cleared.
  88. 当flush()在缓存中被调用时,MemoryStore是否被清除。默认是true,即MemoryStore被清除。
  89. memoryStoreEvictionPolicy:
  90. Policy would be enforced upon reaching the maxElementsInMemory limit. Default
  91. policy is Least Recently Used (specified as LRU). Other policies available -
  92. First In First Out (specified as FIFO) and Less Frequently Used
  93. (specified as LFU)
  94. Cache elements can also contain sub elements which take the same format of a factory class
  95. and properties. Defined sub-elements are:
  96. 当达到maxElementsInMemory限制时,策略将强制执行。策略是最近最少使用的算法(简称为LRU)。其他的策略通用。缓存元素也可以有子元素,子元素拥有相同格式的工厂类和属性。定义的sub-elements有:
  97. /* cacheEventListenerFactory - Enables registration of listeners for cache events, such as
  98. put, remove, update, and expire.
  99. /* cacheEventListenerFactory – 启用缓存事件监听器的注册,如put, remove, update, and expire.
  100. /* bootstrapCacheLoaderFactory - Specifies a BootstrapCacheLoader, which is called by a
  101. cache on initialisation to prepopulate itself.
  102. /* bootstrapCacheLoaderFactory – 指定一个BootstrapCacheLoader,它被一个缓存在初始化时调用,用来预填充自己。
  103. /* cacheExtensionFactory - Specifies a CacheExtension, a generic mechansim to tie a class
  104. which holds a reference to a cache to the cache lifecycle.
  105. /* cacheExtensionFactory – 指定一个CacheExtension,一个通用的mechansim来联系一个保存引用到缓存的类到缓存生命周期。
  106. /* cacheExceptionHandlerFactory - Specifies a CacheExceptionHandler, which is called when
  107. cache exceptions occur.
  108. /* cacheExceptionHandlerFactory – 指定一个CacheExceptionHandler,每当缓存异常出现时调用。
  109. /* cacheLoaderFactory - Specifies a CacheLoader, which can be used both asynchronously and
  110. synchronously to load objects into a cache. More than one cacheLoaderFactory element
  111. can be added, in which case the loaders form a chain which are executed in order. If a
  112. loader returns null, the next in chain is called.
  113. /* cacheLoaderFactory – 指定一个CacheLoader,能够同步和异步装载对象到一个缓存。可以添加多个cacheLoaderFactory元素,在这种情况装载机形成一个链,被有序的执行。如果一个装载机返回null,下一个链就被调用。
  114. Cache Event Listeners
  115. 缓存事件监听器
  116. All cacheEventListenerFactory elements can take an optional property listenFor that describes
  117. which events will be delivered in a clustered environment. The listenFor attribute has the
  118. following allowed values:
  119. 所有的cacheEventListenerFactory元素能选取一个可选属性listenFor描述的事件将在一个集群环境中交付。这个listenFor属性有如下允许的值:
  120. /* all - the default is to deliver all local and remote events
  121. /* local - deliver only events originating in the current node
  122. /* remote - deliver only events originating in other nodes
  123. /* all – 默认交付所有的本地和远程事件
  124. /* local – 交付的只是源于当前节点的事件
  125. /* remote - 交付的只是源于其他节点
  126. Example of setting up a logging listener for local cache events:
  127. 设置一个本地缓存事件监听器的例子:
  128. <cacheEventListenerFactory class="my.company.log.CacheLogger"
  129. listenFor="local" />
  130. Cache Exception Handling
  131. 缓存异常处理
  132. ++++++++++++++++++++++++
  133. By default, most cache operations will propagate a runtime CacheException on failure. An
  134. interceptor, using a dynamic proxy, may be configured so that a CacheExceptionHandler can
  135. be configured to intercept Exceptions. Errors are not intercepted.
  136. 通常,大多数cache运行失败将产生运行时CacheException。通过使用代理,一个拦截器应该被配置,以便于能够配置CacheExceptionHandler拦截异常。错误并不被拦截。
  137. It is configured as per the following example:
  138. 按照下面的例子配置:
  139. <cacheExceptionHandlerFactory class="com.example.ExampleExceptionHandlerFactory"
  140. properties="logLevel=FINE"/>
  141. Caches with ExceptionHandling configured are not of type Cache, but are of type Ehcache only,
  142. and are not available using CacheManager.getCache(), but using CacheManager.getEhcache().
  143. 有ExceptionHandling配置的缓存并不是典型的Cache,但却是典型的Ehcache,并且不能使用CacheManager.getCache(),但能够使用CacheManager.getEhcache()。
  144. Cache Loader
  145. 缓存装载
  146. ++++++++++++
  147. A default CacheLoader may be set which loads objects into the cache through asynchronous and
  148. synchronous methods on Cache. This is different to the bootstrap cache loader, which is used
  149. only in distributed caching.
  150. 一个默认的CacheLoader应该被设置成这样,能够通过Cache中的同步和异步方法装载对象到缓存中。这和仅在分布是缓存中被用到的缓存装载引导程序是不同的。
  151. It is configured as per the following example:
  152. 按照如下示例配置:
  153. <cacheLoaderFactory class="com.example.ExampleCacheLoaderFactory"
  154. properties="type=int,startCounter=10"/>
  155. XA Cache
  156. ++++++++
  157. To enable an ehcache as a participant in the JTA Transaction, just have the following attribute
  158. 使ehcache作为JTA事务的参与者,只需要如下属性。
  159. transactionalMode="xa", otherwise the default is transactionalMode="off"
  160. transactionalMode="xa", 否则,默认是 transactionalMode="off"
  161. Cache Writer
  162. ++++++++++++
  163. A CacheWriter maybe be set to write to an underlying resource. Only one CacheWriter can be
  164. been to a cache.
  165. 一个CacheWriter可以设置写到底层资源中。只有一个CacheWriter能够成为一个cache。
  166. It is configured as per the following example for write-through:
  167. 按照如下示例配置write-through:
  168. <cacheWriterFactory class="net.sf.ehcache.writer.TestCacheWriterFactory"
  169. properties="type=int,startCounter=10"/>
  170. And it is configured as per the following example for write-behind:
  171. 按照如下示例配置write-behind:
  172. <cacheWriter writeMode="write-behind" minWriteDelay="1" maxWriteDelay="5"
  173. rateLimitPerSecond="5" writeCoalescing="true" writeBatching="true" writeBatchSize="1"
  174. retryAttempts="2" retryAttemptDelaySeconds="1">
  175. <cacheWriterFactory class="net.sf.ehcache.writer.TestCacheWriterFactory"
  176. properties="type=int,startCounter=10"/>
  177. The cacheWriter element has the following attributes:
  178. cacheWriter元素有如下属性:
  179. /* writeMode: the write mode, write-through or write-behind
  180. These attributes only apply to write-through mode:
  181. 这些属性仅适用于write-through模式:
  182. /* notifyListenersOnException: Sets whether to notify listeners when an exception occurs on a writer operation.
  183. /* notifyListenersOnException:设置当一个写操作出现异常时是否告知监听器。
  184. These attributes only apply to write-behind mode:
  185. 这些属性仅适用于write-behind模式:
  186. /* minWriteDelay: Set the minimum number of seconds to wait before writing behind. If set to a value greater than 0,
  187. it permits operations to build up in the queue. This is different from the maximum write delay in that by waiting
  188. a minimum amount of time, work is always being built up. If the minimum write delay is set to zero and the
  189. CacheWriter performs its work very quickly, the overhead of processing the write behind queue items becomes very
  190. noticeable in a cluster since all the operations might be done for individual items instead of for a collection
  191. of them.
  192. /* minWriteDelay:设置write-behind之前的等待最小秒数。如果设置值比0大,则允许操作建立在队列中。和最大写入延迟不同,通过等待的最短时间,工作将同时被建立。如果最小写入延迟设置成0,并且CacheWriter快速执行程序,在一个集群中处理队列项目后的写入开销将会非常显著,因为所有的运行被单个项目完成,代替他们的一个集合。
  193. /* maxWriteDelay: Set the maximum number of seconds to wait before writing behind. If set to a value greater than 0,
  194. it permits operations to build up in the queue to enable effective coalescing and batching optimisations.
  195. /* maxWriteDelay:设置在后面写入之前等待的最大秒数。如设置值为0,它允许在队列里建立运行程序,以便有效地合并和批量优化。
  196. /* writeBatching: Sets whether to batch write operations. If set to true, writeAll and deleteAll will be called on
  197. the CacheWriter rather than write and delete being called for each key. Resources such as databases can perform
  198. more efficiently if updates are batched, thus reducing load.
  199. /* writeBatching:设置是否批量写入操作。如果设为true,writeAll 和deleteAll将调用CacheWriter,而不是为每个键调用write和delete。如果更新是批量的,诸如数据库资源可以更高效的执行,因此减少了负荷。
  200. /* writeBatchSize: Sets the number of operations to include in each batch when writeBatching is enabled. If there are
  201. less entries in the write-behind queue than the batch size, the queue length size is used.
  202. /* writeBatchSize:当writeBatching处于激活时,设置每批包含的操作的数目。如果write-behind队列的实体数少于每批的数目,就使用队列的长度。
  203. /* rateLimitPerSecond: Sets the maximum number of write operations to allow per second when writeBatching is enabled.
  204. /* rateLimitPerSecond:当writeBatching激活时,设置写操作每秒允许的最大数目。
  205. /* writeCoalescing: Sets whether to use write coalescing. If set to true and multiple operations on the same key are
  206. present in the write-behind queue, only the latest write is done, as the others are redundant.
  207. /* writeCoalescing: 设置是否使用写入联合。如果设为true并且同样的键有多个操作出现在write-behind队列,只有最新的写入完成,因为其他的成了多余的。
  208. /* retryAttempts: Sets the number of times the operation is retried in the CacheWriter, this happens after the
  209. original operation.
  210. /* retryAttempts:设置CacheWriter中重复操作的总次数,这发生在初次操作之后。
  211. /* retryAttemptDelaySeconds: Sets the number of seconds to wait before retrying an failed operation.
  212. /* retryAttemptDelaySeconds:设置在失败操作重试之前等待的秒数。
  213. Cache Extension
  214. +++++++++++++++
  215. CacheExtensions are a general purpose mechanism to allow generic extensions to a Cache.
  216. CacheExtensions are tied into the Cache lifecycle.
  217. CacheExtensions是一个总的作用机制允许Cache有普通异常。CacheExtensions与Cache生命周期紧密相连。
  218. CacheExtensions are created using the CacheExtensionFactory which has a
  219. createCacheCacheExtension() method which takes as a parameter a
  220. Cache and properties. It can thus call back into any public method on Cache, including, of
  221. course, the load methods.
  222. 创建CacheExtensions 来使用CacheExtensionFactory,他有一个createCacheCacheExtension()方法可以当做一个参数一个Cache和属性。因此CacheExtensions能够回调所有Cache中的公有方法,当然,包括装载方法。
  223. Extensions are added as per the following example:
  224. 按照如下示例增加Extensions:
  225. <cacheExtensionFactory class="com.example.FileWatchingCacheRefresherExtensionFactory"
  226. properties="refreshIntervalMillis=18000, loaderTimeout=3000,
  227. flushPeriod=whatever, someOtherProperty=someValue ..."/>
  228. Terracotta Clustering
  229. +++++++++++++++++++++
  230. Cache elements can also contain information about whether the cache can be clustered with Terracotta.
  231. The sub-element has the following attributes:
  232. Cache元素也包含了有关是否缓存能和Terracotta聚集的信息。子元素有如下属性:
  233. /* clustered=true|false - indicates whether this cache should be clustered with Terracotta. By
  234. default, if the element is included, clustered=true.
  235. /* clustered=true|false – 显示这个cache是否应该和Terracotta聚集。如果包括元素,默认的是clustered=true。
  236. /* valueMode=serialization|identity - indicates whether this cache should be clustered with
  237. serialized copies of the values or using Terracotta identity mode. By default, values will
  238. be cached in serialization mode which is similar to other replicated Ehcache modes. The identity
  239. mode is only available in certain Terracotta deployment scenarios and will maintain actual object
  240. identity of the keys and values across the cluster. In this case, all users of a value retrieved from
  241. the cache are using the same clustered value and must provide appropriate locking for any changes
  242. made to the value (or objects referred to by the value).
  243. /* valueMode=serialization|identity – 指出是否这个cache和值的序列化拷贝聚合或者使用Terracotta鉴定模式。通常,值将会在序列化模式中缓存,这和其他的再生Ehcache模式相似。身份模式只有在某些Terracotta部署方案中有效,并且通过集群保持实际对象身份的键和值。在这种情况下,所有从缓存取值的用户都使用相同的集群值,并且必须对值(或者值所引用的对象)的任何改变提供了合适的锁定。
  244. /* synchronousWrites=true|false - When set to true, clustered caches use
  245. Terracotta SYNCHRONOUS WRITE locks. Asynchronous writes (synchronousWrites="false") maximize performance by
  246. allowing clients to proceed without waiting for a "transaction received" acknowledgement from the server.
  247. Synchronous writes (synchronousWrites="true") maximize data safety by requiring that a client receive server
  248. acknowledgement of a transaction before that client can proceed. If coherence mode is disabled using
  249. configuration (coherent="false") or through the coherence API, only asynchronous writes can occur
  250. (synchronousWrites="true" is ignored). By default this value is false (i.e. clustered caches use normal
  251. Terracotta WRITE locks).
  252. /* synchronousWrites=true|false – 当设为true时,缓存集群使用Terracotta SYNCHRONOUS WRITE锁。异步写入(synchronousWrites="false")最大的性能允许客户端继续而无需等待"transaction received"服务器的回应。同步写入(synchronousWrites="true")最大数据安全性,要求客户端再继续之前接收服务器端的事务响应。如果coherence模式不能使用配置(coherent="false")或者通过coherence API,仅异步写入能够存在(synchronousWrites="true"被忽略)。通常,这个值为false(例. 聚集缓存使用正常的Terracotta WRITE锁)。
  253. /* coherent=true|false - indicates whether this cache should have coherent reads and writes with guaranteed
  254. consistency across the cluster. By default, its value is true. If this attribute is set to false
  255. (or "incoherent" mode), values from the cache are read without locking, possibly yielding stale data.
  256. Writes to a cache in incoherent mode are batched and applied without acquiring cluster-wide locks,
  257. possibly creating inconsistent values across cluster. Incoherent mode is a performance optimization
  258. with weaker concurrency guarantees and should generally be used for bulk-loading caches, for loading
  259. a read-only cache, or where the application that can tolerate reading stale data. This setting overrides
  260. coherentReads, which is deprecated.
  261. /* coherent=true|false – 指出是否这个缓存应使读和写前后一致并通过集群确保其一致性。通常默认值是true。如这个属性被设为false(或"incoherent"模式),缓存里没有锁定直接读取的值,可能产生坏的数据。随着并发保证的减弱,Incoherent模式是最优化性能,应该用于bulk-loading缓存,用于装载一个只读缓存,或用于程序中能够容忍读取损坏数据的地方。这个设置重载了coherentReads,这是不赞成的。
  262. /* copyOnRead=true|false - indicates whether cache values are deserialized on every read or if the
  263. materialized cache value can be re-used between get() calls. This setting is useful if a cache
  264. is being shared by callers with disparate classloaders or to prevent local drift if keys/values
  265. are mutated locally w/o putting back to the cache. NOTE: This setting is only relevant for caches
  266. with valueMode=serialization
  267. /* copyOnRead=true|false – 指出是否每个读出的缓存值是反序列化的,或者,是否具体的缓存值能够在get()调用之间被重用。这个设置很有用,如果一个缓存被不同的类装载器的调用者共享,或是阻止本地偏移如果键/值被组织本地w/o放回缓存。注意:这个设置仅对valueMode=serialization的缓存有意义。
  268. Simplest example to indicate clustering:
  269. 最简单的集群实例:
  270. To indicate the cache should not be clustered (or remove the element altogether):
  271. 指明缓存不被聚集(或一起移除元素)
  272. To indicate the cache should be clustered using identity mode:
  273. 表示使用模式聚集缓存:
  274. To indicate the cache should be clustered using incoherent mode for bulk load:
  275. 对大量的装载使用incoherent模式聚集缓存。
  276. To indicate the cache should be clustered using synchronous-write locking level:
  277. 使用synchronous-write锁定水平应该聚集缓存。
  278. -->
  279. <!--
  280. Mandatory Default Cache configuration. These settings will be applied to caches
  281. created programmtically using CacheManager.add(String cacheName).
  282. 强制预设缓存配置。这个设置将应用于缓存创建CacheManager.add(String cacheName)。
  283. The defaultCache has an implicit name "default" which is a reserved cache name.
  284. defaultCache有一个内涵的名称“default”,是一个预设的缓存名称。
  285. -->
  286. <defaultCache
  287. maxElementsInMemory="0"
  288. eternal="false"
  289. timeToIdleSeconds="1200"
  290. timeToLiveSeconds="1200">
  291. <!--
  292. Sample caches. Following are some example caches. Remove these before use.
  293. 缓存样本。以下是一些缓存实例,在使用前删掉这些。
  294. -->
  295. <!--
  296. Sample cache named sampleCache1
  297. This cache contains a maximum in memory of 10000 elements, and will expire
  298. an element if it is idle for more than 5 minutes and lives for more than
  299. 10 minutes.
  300. 缓存实例名为sampleCache1,这个缓存的最大存储量为10000个元素,如果一个元素空闲时间超过5分钟就会失效并且生命周期超过10分钟。
  301. If there are more than 10000 elements it will overflow to the
  302. disk cache, which in this configuration will go to wherever java.io.tmp is
  303. defined on your system. On a standard Linux system this will be /tmp"
  304. 如果超过了10000个元素,磁盘缓存将会溢出,在这个缓存中,这个配置将找到你系统中任何定义java.io.tmp的地方。在标准的Linux系统中,这将会是/tmp"。
  305. -->
  306. <cache name="sampleCache1"
  307. maxElementsInMemory="10000"
  308. maxElementsOnDisk="1000"
  309. eternal="false"
  310. overflowToDisk="true"
  311. diskSpoolBufferSizeMB="20"
  312. timeToIdleSeconds="300"
  313. timeToLiveSeconds="600"
  314. memoryStoreEvictionPolicy="LFU"
  315. />
  316. <!--
  317. Sample cache named sampleCache2
  318. 实例缓存sampleCache2
  319. This cache has a maximum of 1000 elements in memory. There is no overflow to disk, so 1000
  320. is also the maximum cache size. Note that when a cache is eternal, timeToLive and
  321. timeToIdle are not used and do not need to be specified.
  322. 这个缓存的最大存储容量是1000个元素。没有磁盘溢出,因此,1000也是缓存的最大长度。要注意的是,当缓存持久化后, timeToLive和timeToIdle将不被使用,并且不需要特别指定。
  323. -->
  324. <cache name="sampleCache2"
  325. maxElementsInMemory="1000"
  326. eternal="true"
  327. overflowToDisk="false"
  328. memoryStoreEvictionPolicy="FIFO"
  329. />
  330. <!--
  331. Sample cache named sampleCache3. This cache overflows to disk. The disk store is
  332. persistent between cache and VM restarts. The disk expiry thread interval is set to 10
  333. minutes, overriding the default of 2 minutes.
  334. 示例sampleCache3。这个缓存溢出到磁盘。磁盘存储在缓存和VM重启的时候是持续的。磁盘期满间隔设置为10分钟,覆盖原来的2分钟。
  335. -->
  336. <cache name="sampleCache3"
  337. maxElementsInMemory="500"
  338. eternal="false"
  339. overflowToDisk="true"
  340. timeToIdleSeconds="300"
  341. timeToLiveSeconds="600"
  342. diskPersistent="true"
  343. diskExpiryThreadIntervalSeconds="1"
  344. memoryStoreEvictionPolicy="LFU"
  345. />
  346. <!--
  347. Sample Terracotta clustered cache named sampleTerracottaCache.
  348. This cache uses Terracotta to cluster the contents of the cache.
  349. Terracotta集群缓存示例sampleTerracottaCache。这个缓存使用Terracotta聚集缓存内容。
  350. -->
  351. <cache name="sampleTerracottaCache"
  352. maxElementsInMemory="1000"
  353. eternal="false"
  354. timeToIdleSeconds="3600"
  355. timeToLiveSeconds="1800"
  356. overflowToDisk="false">
  357. <!--
  358. Sample xa enabled cache name xaCache
  359. Xa激活缓存示例xaCache
  360. -->
  361. <cache name="xaCache"
  362. maxElementsInMemory="500"
  363. eternal="false"
  364. timeToIdleSeconds="300"
  365. timeToLiveSeconds="600"
  366. overflowToDisk="false"
  367. diskPersistent="false"
  368. diskExpiryThreadIntervalSeconds="1"
  369. transactionalMode="xa">
  370. 设置完全限定类名被注册为CacheManager事件监听器。
  371. 事件包括:
  372. /* adding a Cache增加一个缓存
  373. /* removing a Cache移除一个缓存
  374. 设置元素是否持久化,如果持久化,将忽视超时并且元素永不过期。
  375. 回调监听器的方法有同步和异步两种。安全的处理潜在的麻烦和线程安全问题将是实施者的责任,这依取决于他们的监听器在干什么。
  376. 如果没有类指定,就不会创建监听器。这里没有默认值。
  377. <!--
  378. TerracottaConfig
  379. ========================
  380. maxElementsOnDisk:
  381. 设置磁盘存储器维持的对象的最大数目。默认是0,意味着没有限制。
  382. eternal:
  383. 激活Terracotta集群选项)
  384. 注意:你需要安装运行一个或多个Terracotta服务器来使用Terracotta集群。
  385. 参看http://www.terracotta.org/web/display/orgsite/Download
  386. 使用多个Terracotta服务器实例URLs(容错能力)的例子
  387. maxElementsInMemory:
  388. 设置创建到存储器中的对象的最大数目。
  389. 在ehcache配置文件中嵌入一个Terracotta配置文件简单的放置一个普通的Terracotta XML配置到元素中。
  390. Example:
  391. app/logs-%i
  392. 更多的Terracotta信息,参看Terracotta文档。
  393. -->
  394. <!--
  395. Cache configuration
  396. ===================
  397. The following attributes are required.
  398. 如下属性都需要:
  399. name:
  400. 设置缓存的名称。用于鉴定缓存,他必须是唯一的。
  401. 指定一个TerracottaConfig用于为CacheManager配置Terracotta运行时。
  402. 配置文件可以通过两种主要方式指定:通过引用配置文件或者使用Terracotta嵌入式配置文件。
  403. 使用URL属性指定一个配置资源(或者多个)的引用。URL属性必须包含一个逗号隔开的列表:
  404. /* path(Terracotta配置文件的路径)(通常命名为 tc-config.xml)
  405. /* URL Terracotta配置文件的URL
  406. /* : Terracotta服务器运行实例
  407. 最简单的例子指出这台机器上的一个Terracotta服务器:
  408. 使用Terracotta配置文件路径的例子:
  409. 使用Terracotta配置文件URL的例子:

  410. <?xml version="1.0" encoding="UTF-8"?> 设置完全限定类名被注册为CacheManager事件监听器。 事件包括: / adding a Cache增加一个缓存 / removing a Cache移除一个缓存 设置元素是否持久化,如果持久化,将忽视超时并且元素永不过期。 回调监听器的方法有同步和异步两种。安全的处理潜在的麻烦和线程安全问题将是实施者的责任,这依取决于他们的监听器在干什么。 如果没有类指定,就不会创建监听器。这里没有默认值。 <!-- Cache configuration =================== The following attributes are required. 如下属性都需要: name: 设置缓存的名称。用于鉴定缓存,他必须是唯一的。 指定一个TerracottaConfig用于为CacheManager配置Terracotta运行时。 配置文件可以通过两种主要方式指定:通过引用配置文件或者使用Terracotta嵌入式配置文件。 使用URL属性指定一个配置资源(或者多个)的引用。URL属性必须包含一个逗号隔开的列表: / path(Terracotta配置文件的路径)(通常命名为 tc-config.xml) / URL Terracotta配置文件的URL /* : Terracotta服务器运行实例 最简单的例子指出这台机器上的一个Terracotta服务器: 使用Terracotta配置文件路径的例子: 使用Terracotta配置文件URL的例子: 分享到:

Spring 3.0.5 MVC 基于注解ehcache.xml 配 ... | 过滤掉非指定保留的html元素,保留元素间的 ...

评论

发表评论

您还没有登录,请您登录后再发表评论

zuzong的博客

zuzong

  • 浏览: 24410 次
  • 性别: Icon_minigender_1
  • 来自: 济南
  • 最近访客 更多访客>>

小菜菜的博客

小菜菜

donald3003a的博客

donald3003a china_ymex的博客

china_ymex

dylinshi126的博客

dylinshi126

文章分类

存档分类

希望本站内容对您有点用处,有什么疑问或建议请在后面留言评论
转载请注明作者(RobinChia)和出处 It so life ,请勿用于任何商业用途
本文链接: EhCache配置文件