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。

最新文章

  1. 手把手教你做个人 app
  2. Android Touch事件传递机制详解
  3. oracle ebs应用产品安全性-交叉验证规则
  4. JOST数据 日期转换
  5. 建立mvc过程
  6. Nagios NSclient Failed to get CPU value: \238(_total)\6: Failed to get mutex :(
  7. 一、Maya API简介
  8. PHP 计算出内存最高占用.
  9. ARM architectures
  10. memcached 学习笔记
  11. mysql 事务类型表的用法
  12. cocos2d-x学习知识点记录
  13. 【转】ThinkPHP中数据库操作返回值总结
  14. 深入学习微框架Spring-boot
  15. python手记(44)
  16. HTTP 状态代码及其定义
  17. springMvc 支持hibernate validator
  18. JavaScript高级编程
  19. 5.MyBaits调用存储过程
  20. 如何获取DOM中当前获取焦点的元素

热门文章

  1. 一步一步学android之控件篇——ListView基本使用
  2. js 万恶之源 是否滚动到底部?
  3. 转:zTree树控件实战篇:针对多个下拉加载zTree树应该如何做出合理的配置
  4. WPF中动态改变控件显示位置
  5. Android USB配件模式
  6. Android 开发日常积累
  7. Libgdx之Music Sound 音效
  8. HTML5学习笔记(十二):JavaScript新增Map和Set
  9. KVM虚拟机安装报错 KVM is not available
  10. [CoreOS]CoreOS 实战:CoreOS 及管理工具介绍