ehcache配置参数说明

Cache配置


以下属性是必须的
name:Cache的唯一标识名称
Sets the name of the cache. This is used to identify the cache. It must be unique.


maxEntriesLocalHeap:堆内存中最大缓存对象数,0没有限制
Sets the maximum number of objects that will be held on heap memory.  0 = no limit.


maxEntriesLocalDisk:磁盘中的最大对象数,默认为0不限制
Sets the maximum number of objects that will be maintained in the DiskStore
The default value is zero, meaning unlimited.


eternal:elements是否永久有效,如果为true,timeouts将被忽略,element将永不过期
Sets whether elements are eternal. If eternal,  timeouts are ignored and the
element is never expired.


The following attributes and elements are optional.
以下属性是可选的


maxEntriesInCache:只能用在Terracotta distributed caches.
    This feature is applicable only to Terracotta distributed caches.
    Sets the maximum number of entries that can be stored in the cluster. 0 = no limit.
    Note that clustered cache will still perform eviction if resource usage requires it.
    This property can be modified dynamically while the cache is operating.


overflowToOffHeap:只能用于企业版本中
    (boolean) This feature is available only in enterprise versions of Ehcache.
    When set to true, enables the cache to utilize off-heap memory
    storage to improve performance. Off-heap memory is not subject to Java
    GC. The default value is false.2


maxBytesLocalHeap:如果设置了这个属性,maxEntriesLocalHeap将不能被利用
    Defines how many bytes the cache may use from the VM's heap. If a CacheManager
    maxBytesLocalHeap has been defined, this Cache's specified amount will be
    subtracted from the CacheManager. Other caches will share the remainder.
    This attribute's values are given as k|K|m|M|g|G for
    kilobytes (k|K), megabytes (m|M), or gigabytes (g|G).
    For example, maxBytesLocalHeap="2g" allots 2 gigabytes of heap memory.
    If you specify a maxBytesLocalHeap, you can't use the maxEntriesLocalHeap attribute.
    maxEntriesLocalHeap can't be used if a CacheManager maxBytesLocalHeap is set.


    Elements put into the cache will be measured in size using net.sf.ehcache.pool.sizeof.SizeOf
    If you wish to ignore some part of the object graph, see net.sf.ehcache.pool.sizeof.annotations.IgnoreSizeOf


maxBytesLocalOffHeap:只能用于企业版本中
    This feature is available only in enterprise versions of Ehcache.
    Sets the amount of off-heap memory this cache can use, and will reserve.


    This setting will set overflowToOffHeap to true. Set explicitly to false to disable overflow behavior.


    Note that it is recommended to set maxEntriesLocalHeap to at least 100 elements
    when using an off-heap store, otherwise performance will be seriously degraded,
    and a warning will be logged.


    The minimum amount that can be allocated is 128MB. There is no maximum.


maxBytesLocalDisk:像maxBytesLocalHeap属性
    As for maxBytesLocalHeap, but specifies the limit of disk storage this cache will ever use.


timeToIdleSeconds:失效前的空闲秒数,当eternal为false时,这个属性才有效,0为不限制
    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.


timeToLiveSeconds:失效前的存活秒数,创建时间到失效时间的间隔为存活时间,当eternal为false时,这个属性才有效,0为不限制
    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.


diskExpiryThreadIntervalSeconds:
    The number of seconds between runs of the disk expiry thread. The default value
    is 120 seconds.


diskSpoolBufferSizeMB:这个参数设置DiskStore(磁盘缓存)的缓存区大小。默认是30MB。每个Cache都应该有自己的一个缓冲区。
    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.


clearOnFlush:当调用flush()是否清除缓存,默认是
    whether the MemoryStore should be cleared when flush() is called on the cache.
    By default, this is true i.e. the MemoryStore is cleared.


memoryStoreEvictionPolicy:内存回收策略,默认回收策略:最近最少使用Least Recently Used,先进先出First In First Out,Less Frequently Used使用频率最低
    Policy would be enforced upon reaching the maxEntriesLocalHeap 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)


copyOnRead:
    Whether an Element is copied when being read from a cache.
    By default this is false.


copyOnWrite:
    Whether an Element is copied when being added to the cache.
    By default this is false.


    Cache persistence is configured through the persistence sub-element.  The attributes of the
    persistence element are:


strategy:
    Configures the type of persistence provided by the configured cache.  This must be one of the
    following values:


    * localRestartable - Enables the RestartStore and copies all cache entries (on-heap and/or off-heap)
    to disk. This option provides fast restartability with fault tolerant cache persistence on disk.
    It is available for Enterprise Ehcache users only.


    * localTempSwap - Swaps cache entries (on-heap and/or off-heap) to disk when the cache is full.
    "localTempSwap" is not persistent.


    * none - Does not persist cache entries.


    * distributed - Defers to the configuration for persistence settings. This option
    is not applicable for standalone.
    
synchronousWrites:
    When set to true write operations on the cache do not return until after the operations data has been
    successfully flushed to the disk storage.  This option is only valid when used with the "localRestartable"
    strategy, and defaults to false.

你可能感兴趣的:(Java)