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. [转]同一个tomcat不同项目的session共享问题

    问题描述: session常常用来存储一些公共信息供不同页面访问,比如用户登录信息.访问同一个tomcat下的不同项目所创建的session是不一样的.自然地面临了如何共享session的问题. 解决 ...

  2. 解决iPad/iPhone下手机号码会自动被加上a标签的问题

    解决办法: 在页面顶部<head></head>中增加: <meta name="format-detection" content="te ...

  3. Elastalert 监控

    1.logstash 做监控的优劣 适合match-then-alert 的方式 logstash-filter-metric logstash-input-http_poller 无状态.进程间数据 ...

  4. AdminLTE, Color Admin

    AdminLTE, Color Adminhttps://github.com/almasaeed2010/AdminLTE/http://www.seantheme.com/color-admin- ...

  5. 趣味讲解:移动互联网 VS 传统互联网

    趣味讲解:移动互联网 VS 传统互联网 太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用途-保持一致"创作公用协议 转 ...

  6. SQL Server中利用正则表达式替换字符串

    --如果存在则删除原有函数  IF OBJECT_ID(N'dbo.RegexReplace') IS NOT NULL       DROP FUNCTION dbo.RegexReplace  G ...

  7. HTML杂记

    1.URL  uniform resource locator 遵循格式: scheme://host.domain:port/path/filename scheme - 定义因特网服务的类型.最常 ...

  8. FFmpeg(12)-使用NDK通过GLSurfaceView完成视频的播放

    一.包含头文件和库文件 这里采用的是NDK中的ANativeWindow来完成视频的播放,因为需要添加相关的库和头文件. CMakeLists target_link_libraries( # Spe ...

  9. 每日英语:Got 5 Minutes? 'Flash Fiction' Catches On

    Chinese author Lao Ma has a simple approach to his short stories: In the face of life, everything is ...

  10. Android 编程下 TextView 添加链接的一种方式

    通过如下这种方式给 TextView 添加的链接支持链接样式.点击事件.href 样式,代码如下: package cn.sunzn.tlink; import android.app.Activit ...