zoukankan      html  css  js  c++  java
  • EhCache 配置信息

    How to Size Caches

    官方文档:http://ehcache.org/documentation/configuration/cache-size

    [maxEntriesLocalHeap,maxBytesLocalHeap]

    maxEntriesLocal:设置在Java堆当中缓存元素的数量(默认值0表示无限制),maxBytesLocalHeap设置在Java堆当中缓存元素的字节大小(默认值0表示无限制),两者不能同时指定。

    如果设置为CacheManager级别的,那么只允许设置maxBytesLocalHeap,设置对CacheManager下所有的cache有效。

     

    [maxBytesLocalOffHeap]

    maxBytesLocalOffHeap:设置离堆内存大小,该设置只在企业版有效,需要BigMemory。

     

    [maxEntriesLocalDisk,maxBytesLocalDisk]

    maxEntriesLocalDisk:设置缓存到磁盘上的元素数量,maxBytesLocalDisk设置缓存到磁盘上的元素的字节大小,默认值都是0,表示无限制,分布式的缓存不能使用该属性。

     

    Attributes that set a number of entries take an integer. Attributes that set a memory size (bytes) use the Java -Xmx syntax (for example: "500k", "200m", "2g") or percentage (for example: "20%"). Percentages, however, can be used only in the case where a CacheManager-level pool has been configured (see below).

     

    You can constrain the size of any cache on a specific tier in that cache's configuration. You can also constrain the size of all of a CacheManager's caches in a specific tier by configuring an overall size at the CacheManager level.

    你可以再cache的配置中闲置换的大小,也可以再ehcache的配置里限制所有缓存的大小。

     

    If there is no CacheManager-level pool specified for a tier, an individual cache claims the amount of that tier specified in its configuration. If there is a CacheManager-level pool specified for a tier, an individual cache claims that amount from the pool. In this case, caches with no size configuration for that tier receive an equal share of the remainder of the pool (after caches with explicit sizing configuration have claimed their portion).

    如果没有定义CacheManager级别的配置,那么cache单独计算它自己配置的缓存大小,如果定义了CacheManager级别的配置,那么所有缓存平均分配总大小,除非cache中明确定义了自己的大小。

    For example, if CacheManager with eight caches pools one gigabyte of heap, and two caches each explicitly specify 200MB of heap while the remaining caches do not specify a size, the remaining caches will share 600MB of heap equally. Note that caches must use bytes-based attributes to claim a portion of a pool; entries-based attributes such as maxEntriesLocal cannot be used with a pool.

    例如,如果一个CacheManager有8个缓存,设置了一个G的堆大小,其中2个缓存定义了200M,其余的缓存没有定义大小,其余的缓存会共享剩余的600M的大小(平均分配),注意 缓存必须配置bytes类型的属性,比如maxEntriesLocal 这种属性不能设置。

    On startup, the sizes specified by caches are checked to ensure that any CacheManager-level pools are not over-allocated. If over-allocation occurs for any pool, an InvalidConfigurationException is thrown. Note that percentages should not add up to more than 100% of a single pool.

    在启动时,缓存会检查CacheManager的容量不会被过度分配,如果发生过度分配,会抛出异常,注意百分比不能超过100%。

    timeToIdleSeconds : 元素的空闲时间,指元素在这个时间内没有被访问,那么就会被淘汰。默认是0表示无限制。

    例如:空闲时间设置为30秒,那么从元素放入缓存的那一刻开始倒计时30秒,如果在30秒内该元素没有被访问,那么就会被淘汰,如果被访问,那么会重新倒计时30秒。

    timeToLiveSeconds:元素的存活时间,指元素在缓存中的存活时间,到了这个时间元素就会被淘汰,无论使用与否。

    例如:存活时间设置为10分钟,那么从元素放入远程的那一刻开始,10分钟以后这个元素就会被淘汰。无论这个元素被访问了多少次。

    eternal:永不过期,如果设置了这个属性,那么忽略timeToIdleSeconds 和 timeToLiveSeconds。

    copyOnRead,copyOnWrite 

    在put或者get的时候返回对象的拷贝,而不是对象引用。默认值为FALSE。

     

  • 相关阅读:
    JAVA地址通过百度地图API转化为经纬度
    JS验证手机号
    JAVA获取六位随机数
    JS判断是否为“YYYYMMDD”式的日期
    JAVA 通过url下载图片保存到本地
    JAVA汉字转拼音
    JS判断是否是苹果系统(ios)和安卓系统(Android)客户端
    JAVA获取请求链接中所有参数(GET请求)
    如何高效学习 Kubernetes 知识图谱?
    当云原生遇到混合云:如何实现“求变”与“求稳”的平衡
  • 原文地址:https://www.cnblogs.com/daxin/p/3988278.html
Copyright © 2011-2022 走看看