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。

EhCache 配置信息的更多相关文章

  1. Hibernate4+EhCache配置二级缓存

    本文主要讲一讲Hibernate+EhCache配置二级缓存的基本使用方法 (有关EhCache的基础介绍可参见:http://sjsky.iteye.com/blog/1288257 ) Cache ...

  2. maven Web项目中POM的配置信息

    什么是POM? POM是项目对象模型(Project Object Model)的简称,它是Maven项目中的文件,使用XML表示,名称叫做pom.xml.在Maven中,当谈到Project的时候, ...

  3. ehcache 配置持久化到硬盘(四)

    Ehcache默认配置的话 为了提高效率,所以有一部分缓存是在内存中,然后达到配置的内存对象总量,则才根据策略持久化到硬盘中,这里是有一个问题的,假如系统突然中断运行 那内存中的那些缓存,直接被释放掉 ...

  4. MyCat源码分析系列之——配置信息和启动流程

    更多MyCat源码分析,请戳MyCat源码分析系列 MyCat配置信息 除了一些默认的配置参数,大多数的MyCat配置信息是通过读取若干.xml/.properties文件获取的,主要包括: 1)se ...

  5. ASP.NET CORE配置信息

    做个笔记,原文链接 除了应用 IOptions<T> .Value的方式对配置信息进行全局注册外可以应用的另一个微软给出的组件,需要依赖两个包 Microsoft.Extensions.C ...

  6. Tomcat下conf下server.xml的文件配置信息

    Tomcat下conf下server.xml的文件配置信息,基本上不用做任何修改就可以使用,修改的地方就是host区域的一些配置,此文件设置端口为80. 注意:Tomcat配置文件中(即server. ...

  7. 如何方便的保存WinForm窗体控件的位置大小等等配置信息

    由于分辨率.屏幕主题.字体大小的不同,窗体显示效果在不同机器上不尽相同.窗体的弹性设计并不能满足多样的需求.为保证在各种情况下,能有满意的效果.窗体的多样显示方式能改变,并且保存.载入配置,显得很重要 ...

  8. ASP.NET Core的配置(1):读取配置信息

    提到"配置"二字,我想绝大部分.NET开发人员脑海中会立马浮现出两个特殊文件的身影,那就是我们再熟悉不过的app.config和web.config,多年以来我们已经习惯了将结构化 ...

  9. mate-desktop安装在其他目录时一些配置信息

    1.mate-desktop安装在其他目录时一些配置信息 2.BIN目录下添加相应的mate-session_gtk2/3 3.首先配置如下环境变量 #!/bin/sh if [[ "${E ...

随机推荐

  1. FreeSWITCH呼叫参数之sip_cid_type

    这个参数定义了呼叫中主叫信息的头字段类型.支持两种类型: 1. rpidRemote-Party-ID头,这是默认的设置.{sip_cid_type=rpid}sofia/default/user@e ...

  2. 一些http或https请求的参数,什么情况下需要urlencode编码

    http协议中参数的传输是"key=value"这种简直对形式的,如果要传多个参数就需要用“&”符号对键值对进行分割.如"?name1=value1&na ...

  3. 使用 sqlyog 导入导出数据显示 lost connection to mysql server during query

    mysql中经常需要备份数据,在使用 sqlyog 进行备份数据库为转储文件,然后在其他数据库中导入发生 lost connection 经过查询大量资料是数据库配置的 max_allowed_pac ...

  4. 电子证据 利用Kali进行wifi钓鱼实战详细教程

    电子证据 利用Kali进行wifi钓鱼实战详细教程 一. Kali系统安装和必要软件安装: 1.Kali最新版可以来我这儿拿外置驱动和光盘装,目测用U盘装最新版有些问题,比较麻烦. 2.Kali更新源 ...

  5. influxdb 配置文件注释

    ### Welcome to the InfluxDB configuration file. # The values in this file override the default value ...

  6. [hihoCoder] 第四十八周: 拓扑排序·二

    题目1 : 拓扑排序·二 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 小Hi和小Ho所在学校的校园网被黑客入侵并投放了病毒.这事在校内BBS上立刻引起了大家的讨论,当 ...

  7. 使用gradle多渠道打包

    以友盟的多渠道打包为例,如果我们须要打包出例如以下渠道:UMENG, WANDOUJIA, YINGYONGBAO. 第一种方法.是须要创建文件的. 我们在写完我们的代码之后,在app/src以下.分 ...

  8. 基于Xilinx Zynq Z7045 SoC的CNN的视觉识别应用

    基于Xilinx Zynq Z7045 SoC的CNN的视觉识别应用 由 judyzhong 于 星期三, 08/16/2017 - 14:56 发表 作者:stark 近些年来随着科学技术的不断进步 ...

  9. [na]IP分片抓包实验

    这两点比较重要 1.IP+ICMP+DATA = 1500字节 2.ping size指定的是data的大小. 3,可以ping大包+不分片检测mtu(分片发生在出口,如果包尺寸大于接口ip mtu, ...

  10. OC中几种延时操作的比較

    1. sleepForTimeInterval,此函数会卡住当前线程,一般不用 <span style="font-size:18px;">[NSThread slee ...