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. c2java select algorithm

    对于非常多应用来说,随机算法是最简单的或者最快的.既简单又快的有没有呢? 那须要深刻的洞察力或者革命性的突破. 什么是随机算法 随机算法与确定算法差别是:它还接收输入随机比特流来做随机决策. 对于同一 ...

  2. 10.翻译:EF基础系列---EF中的持久性

    原文链接:http://www.entityframeworktutorial.net/EntityFramework4.3/persistence-in-entity-framework.aspx ...

  3. List遍历Java 8 Streams map() examples

    1. A List of Strings to Uppercase 1.1 Simple Java example to convert a list of Strings to upper case ...

  4. 并发测试 JavaDemo

    https://github.com/oldratlee/fucking-java-concurrency /** * @author Jerry Lee */ public class Testee ...

  5. 用python参加Kaggle的经验总结【转】

    用python参加Kaggle的经验总结 转载自:http://www.jianshu.com/p/32def2294ae6,作者 JxKing    最近挤出时间,用python在kaggle上试了 ...

  6. 基础002_V7-CLB

    一.综述 参考ug474.pdf: 7系列中,一个CLB包含两个slice: 每个CLB的资源: CLB可配置的主要功能: 二.主要功能 LUT是基本单元,例如选择器assign muxout =  ...

  7. 【OfficeWebViewer】在线预览Word,Excel~

    今天有个需求, 直接支持web端预览word,excel等文件, 查了一下很多写的比较麻烦, 这里找到一种简单的方式: http://view.officeapps.live.com/op/view. ...

  8. rsync同步时出现rsync: failed to set times on “xxxx”: Operation not permitted

    今天在同步数据的时候提示rsync: failed to set times on “xxxx”: Operation not permitted,一般来说要不是服务器时间不对或者权限没有设置好,下面 ...

  9. Android基础知识之屏幕兼容模式

    原文:http://android.eoe.cn/topic/android_sdk 注意:如果你在低于安卓3.0的版本上进行应用开发,但其在更大屏幕的设备(比如平板电脑)上显示正常时,你就需要禁用屏 ...

  10. CentOS编译安装vim

    #删除系统自带的vim rpm -qa | grep vim rpm -e vim-X11-7.4.629-5.el6_8.1.x86_64 vim-filesystem-7.4.629-5.el6_ ...