码迷,mamicode.com
首页 > 系统相关 > 详细

第一章:关于Ehcache

时间:2017-11-27 17:54:23      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:ace   堆内存   amount   imp   不同的   using   存储   doc   流程图   

 PDF官方文档:http://www.ehcache.org/generated/2.10.4/pdf/About_Ehcache.pdf

1、什么是Ehcache?

Ehcache是一种开源的基于标准的缓存,用于提高性能和减轻数据库负荷,是当今使用最广泛的基于java的缓存。

 

2、基本术语

  • 缓存:维基词典将缓存定义为"存储将要被使用的东西,并且可以被快速检索"。缓存是一组临时数据,要么是其它地方的数据副本,或者是计算的结果。已经在缓存中的数据可以在时间和资源方面以最小的成本重复访问。
  • 缓存命中:当从缓存请求数据元素时,对于给定的键存在元素,这被称为缓存命中。
  • 缓存未命中:当从缓存请求数据元素时,对于给定的键不存在元素,这被称为缓存未命中。
  • 记录系统:数据的权威性来源,存储层中的最底层。它通常是一种传统的数据库,可能是一个专门的文件系统或者其他可靠的长期存储。

 

3、分层缓存的概念

3.1 存储层介绍

Storage Tiers

Ehcache 3, as in previous versions, offers a tiering model to allow storing increasing amounts of data on slower tiers (which are generally more abundant).

The idea is that resources related to faster storage are more rare, but are located where the ‘hottest‘ data is preferred to be. Thus less-hot (less frequently used) data is moved to the more abundant but slower tiers. Hotter data is moved onto the faster tiers.

译:Ehcache 3和以前的版本一样,提供了一种分层模型,允许在较慢的层上存储更多的数据。

速度更快的存储层一般资源更少。因此,不太常用的数据被转移到更丰富但速度较慢的层,而更常用的数据被转移到更快的层。

 

You can configure Ehcache to use various data storage areas. When a cache is configured to use more than one storage area, those areas are arranged and managed as tiers. They are organized in a hierarchy, with the lowest tier (farther) being called the authority tier and the others being part of the caching tier (nearer, also called near cache) . The caching tier can itself be composed of more than one storage area. The hottest data is kept in the caching tier, which is typically less abundant but faster than the authority tier. All the data is kept in the authority tier, which is slower but more abundant.

Data stores supported by Ehcache include:

  • On-Heap Store - Utilizes Java’s on-heap RAM memory to store cache entries. This tier utilizes the same heap memory as your Java application, all of which must be scanned by the JVM garbage collector. The more heap space your JVM utilizes, the more your application performance will be impacted by garbage collection pauses. This store is extremely fast, but is typically your most limited storage resource.

  • Off-Heap Store - Limited in size only by available RAM. Not subject to Java garbage collection (GC). Is quite fast, yet slower than the On-Heap Store because data must be moved to and from the JVM heap as it is stored and re-accessed.

  • Disk Store - Utilizes a disk (file system) to store cache entries. This type of storage resource is typically very abundant but much slower than the RAM-based stores. As for all application using disk storage, it is recommended to use a fast and dedicated disk to optimize the throughput.

  • Clustered Store - This data store is a cache on a remote server. The remote server may optionally have a failover server providing improved high availability. Since clustered storage comes with performance penalties due to such factors as network latency as well as for establishing client/server consistency, this tier, by nature, is slower than local off-heap storage.

技术分享图片

译:存储层中的最底层被命名为权威层(authority tier ,资源量最丰富的层),一般是磁盘存储层(Disk Tier)或集群存储层(Clustered Tier),其它更近访问更快的层有堆内存储层(Heap tier)和堆外存储层(Off Heap Tier)

Ehcache支持的数据存储包括:

  • 堆内存储 - 利用Java的堆内存来存储缓存条目。使用与Java应用程序相同的由JVM垃圾收集器管理的堆内存。JVM使用的堆空间越多,应用程序性能受到的垃圾收集暂停影响越大。此存储最快但空间最小。
  • 堆外存储 - 只有可用RAM限制大小。不受Java垃圾收集(GC)的影响。它的速度非常快,但比堆内存储要慢,因为数据的存储和重新访问的都要经过堆内存储层。 
  • 磁盘存储 - 利用磁盘(文件系统)来存储缓存条目。这种类型的存储资源通常非常丰富,但是比基于ram的存储要慢得多。对于使用磁盘存储的所有应用程序,建议使用一个快速且专用的磁盘来优化吞吐量。
  • 集群存储 - 这个数据存储是远程服务器上的一个缓存。远程服务器可以有选择地提供一个故障转移服务器使可用性更高。集群存储由于网络延迟和建立客户机/服务器一致性等因素而受到性能的惩罚,因此这一层的性能比本地的堆外存储要慢。

来自官方:http://www.ehcache.org/documentation/3.4/caching-concepts.html#storage-tiers

 

3.2 缓存操作在多存储层中的序列流程图

Sequence Flow for Cache Operations with Multiple Tiers

In order to understand what happens for different cache operations when using multiple tiers, here are examples of Put and Get operations. The sequence diagrams are oversimplified but still show the main points.
技术分享图片

 Figure 2. Multiple tiers using Put

技术分享图片

 Figure 3. Multiple tiers using Get

 

You should then notice the following:

  • When putting a value into the cache, it goes straight to the authoritative tier, which is the lowest tier.

  • A following get will push the value upwards in the caching tiers.

  • Of course, as soon as a value is put in the authoritative tier, all higher-level caching tiers are invalidated.

  • A full cache miss (the value isn’t on any tier) will always go all the way down to the authoritative tier.

译:为了理解在使用多个层时不同的缓存操作会发生什么情况,图为Put和Get操作的示例。序列图过于简化,但仍然显示了要点。

你应该注意到以下几点:

  • 当将一个值放入缓存时,它会直接转到权威层,这是最底层。
  • get将在缓存层中向上推送值。
  • 一旦将值放入到权威层中,所有更近的缓存层都将失效。
  • 缓存丢失(值不在任何层上)总是会一直向下获取直到权威层。

来自官方:http://www.ehcache.org/documentation/3.4/tiering.html#multi-tier-sequence-flow

 

第一章:关于Ehcache

标签:ace   堆内存   amount   imp   不同的   using   存储   doc   流程图   

原文地址:http://www.cnblogs.com/cjh-notes/p/7898398.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!