Ehcache - cache 配置说明翻译

<!-- Cache configuration. Cache配置


    The following attributes are required.如下属性是必须的


    name:

    Sets the name of the cache. This is used to identify the cache. It must be unique.

    设置Cache的名称,必须唯一

    maxElementsInMemory:

    Sets the maximum number of objects that will be created in memory (0 == no limit)

    设置内存中对象的最大数据,0表示无限制

    maxElementsOnDisk:

    Sets the maximum number of objects that will be maintained in the DiskStore

    The default value is zero, meaning unlimited.

    设置磁盘存储中的最大数目,0表示无限制

    eternal:

    Sets whether elements are eternal. If eternal,  timeouts are ignored and the

    element is never expired.

    设置元素是否是永恒的,如果永恒,过期(timeout)设置将被忽略。缓存中的元素将永不过期

    overflowToDisk:

    Sets whether elements can overflow to disk when the in-memory cache

    has reached the maxInMemory limit.

    设置元素是否可以溢出到磁盘上,当内存中的元素数目也达到最大限制


    The following attributes are optional.

    以下属性是可选的

    timeToIdleSeconds:

    Sets the time to idle for an element before it expires.

    i.e. The maximum amount of time between accesses before an element expires

    Is only used if the element is not eternal.

    Optional attribute. A value of 0 means that an Element can idle for infinity.

    The default value is 0.

    设置一个元素过期之前的闲置时间,相当于 元素过期前,两次访问之前的最大间隔时间,只有缓存设置不是永恒(eternal)时才有效。可选属性,当前值为0时表示元素只可以无限期闲置。缺省值就是0

    timeToLiveSeconds:

    Sets the time to live for an element before it expires.

    i.e. The maximum time between creation time and when an element expires.

    Is only used if the element is not eternal.

    Optional attribute. A value of 0 means that and Element can live for infinity.

    The default value is 0.

    设置一个元素过期前的存活时间,相当于元素创建到过期之间的最大时间,只有缓存设置不是永恒(eternal)时才有效。可选属性,当值为0时表时可无限期存活,缺省值为0。

    diskPersistent:

    Whether the disk store persists between restarts of the Virtual Machine.

    The default value is false.

    磁盘持久化,当虚拟机重启时是否进行磁盘存储持久化,缺省是false。


    diskExpiryThreadIntervalSeconds:

    The number of seconds between runs of the disk expiry thread. The default value

    is 120 seconds.

    diskExpiryThreadIntervalSeconds: 两次运行磁盘到期线程的时间间隔,缺省值是120秒=2分钟。注:不知道这个disk expiry thread是干吗的,估计是用来检测磁盘上是否存在过期元素的线程。

    diskSpoolBufferSizeMB:

    This is the size to allocate the DiskStore for a spool buffer. Writes are made

    to this area and then asynchronously written to disk. The default size is 30MB.

    Each spool buffer is used only by its cache. If you get OutOfMemory errors consider

    lowering this value. To improve DiskStore performance consider increasing it. Trace level

    logging in the DiskStore will show if put back ups are occurring.

    diskSpoolBufferSizeMB: 磁盘卷缓存大小(MB)。用于为磁盘存储分配卷缓存的大小。数据会先被写入内存中的该区域,然后再异步写入到磁盘中。缺省大小是30MB, 每个卷缓存只能被它自己的缓存所使用。如果碰到内存溢出时,可考虑降低这个值。需要提高磁盘存储的性能时,可以考虑增加它。将DiskStore的Trace级别的日志打开,会显示存入存出操作的发生。

    memoryStoreEvictionPolicy:

    Policy would be enforced upon reaching the maxElementsInMemory limit. Default

    policy is Least Recently Used (specified as LRU). Other policies available -

    First In First Out (specified as FIFO) and Less Frequently Used

    (specified as LFU)

    MemoryStoreEvicationPolicy:内存存储赶出策略。缺省策略是最近最少使用(LRU),理论上应该是将闲置时间最长的记录先移出。其它策略:先入先出 (FIFO)和使用最少(使用次数最少)


    Cache elements can also contain sub elements which take the same format of a factory class

    and properties. 缓存标签可以拥有子标签,这些子标签可以拥有相同格式的工厂类与属性


Defined sub-elements are:这些子标签元素如下:

    * cacheEventListenerFactory - Enables registration of listeners for cache events, such as

      put, remove, update, and expire.

       cacheEventListenerFactory - 激活缓存事件监听器的注册,例如, pub, remove, update, 和expire   


    * bootstrapCacheLoaderFactory - Specifies a BootstrapCacheLoader, which is called by a

      cache on initialisation to prepopulate itself.

    bootstrapCacheLoaderFactory- 指定一个BootstrapCacheLoader, 当缓存在初始化时被调用从而预填充自己。


    Each cache that will be distributed needs to set a cache event listener which replicates

    messages to the other CacheManager peers. For the built-in RMI implementation this is done

    by adding a cacheEventListenerFactory element of type RMICacheReplicatorFactory to each

    distributed cache's configuration as per the following example:

    每个将要被分布处理的缓存需要设置一个缓存事件监听器,用来复制消息给其它同级的CacaeManager. 对于内置的RMI实现,它是通过为每个分布式缓存配置添加一个类型为RMICacheReplicatorFactory的cacheEventListenerFactory标签元素来完成的,示例如下


    <cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"

         properties="replicateAsynchronously=true,

         replicatePuts=true,

         replicateUpdates=true,

         replicateUpdatesViaCopy=true,

         replicateRemovals=true "/>


    The RMICacheReplicatorFactory recognises the following properties:

RMICacheReplicatorFactory类可以识别以下属性


    * replicatePuts=true|false - whether new elements placed in a cache are

      replicated to others. Defaults to true.

        是否一个新的缓存元素应该被复制到其它的缓存中,缺省是true.

    * replicateUpdates=true|false - whether new elements which override an

      element already existing with the same key are replicated. Defaults to true.

       是否一个新元素覆盖一个已经存在的元素时应该被复制。缺少是true.

    * replicateRemovals=true - whether element removals are replicated. Defaults to true.

        是否一个元素移除时应该被复制。缺省是true.   

    * replicateAsynchronously=true | false - whether replications are

      asynchronous (true) or synchronous (false). Defaults to true.

        是否消息复制应该是异步的,缺省是true。false时说明同步的

    * replicateUpdatesViaCopy=true | false - whether the new elements are

      copied to other caches (true), or whether a remove message is sent. Defaults to true.

     是否复制产生新元素应该被重复到其它缓存,缺省为true


    * asynchronousReplicationIntervalMillis=<number of milliseconds> - The asynchronous

      replicator runs at a set interval of milliseconds. The default is 1000. The minimum

      is 10. This property is only applicable if replicateAsynchronously=true

      异步重复器执行时间间隔,单位毫秒,缺省是1000,即1秒,最小是10.该属性只有当允许异步重复时才生效。

    * asynchronousReplicationMaximumBatchSize=<number of operations> - The maximum

      number of operations that will be batch within a single RMI message.  The default

      is 1000. This property is only applicable if replicateAsynchronously=true

     在一个RMI消息中允许的最大操作数,缺省昌1000。  该属性只有当允许异步重复时才生效。

    The RMIBootstrapCacheLoader bootstraps caches in clusters where RMICacheReplicators are

    used. It is configured as per the following example:

   RMIBootstrapCacheLoader,在群集缓存中使用RMICacheReplicators,时用来启动缓存,配置实例如下

    <bootstrapCacheLoaderFactory

        class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory"

        properties="bootstrapAsynchronously=true, maximumChunkSizeBytes=5000000"/>


    The RMIBootstrapCacheLoaderFactory recognises the following optional properties:

RMIBootstrapCacheLoaderFactory识别如下可选 属性

    * bootstrapAsynchronously=true|false - whether the bootstrap happens in the background

      after the cache has started. If false, bootstrapping must complete before the cache is

      made available. The default value is true.

是否缓存在启动后,引导过程在在后台进行。如果是否的话,引导必须在缓存可用之前就完成。缺省是true.


    * maximumChunkSizeBytes=<integer> - Caches can potentially be very large, larger than the

      memory limits of the VM. This property allows the bootstraper to fetched elements in

      chunks. The default chunk size is 5000000 (5MB).

缓存潜在可能是很大的,甚至比VM的内存还要大,这个属性允许引导器按块来取缓存元素。缺省块大小是5M。

    -->


转载于:https://my.oschina.net/sqzy/blog/464202

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值