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的更多相关文章

  1. Java Persistence with MyBatis 3(中文版) 第一章 MyBatis入门

    本章将涵盖以下话题: ž  MyBatis是什么? ž  为什么选择MyBatis? ž  MyBatis安装配置 ž  域模型样例 1.1 MyBatis是什么 MyBatis是一个简化和实现了Ja ...

  2. 《Django By Example》第一章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:本人目前在杭州某家互联网公司工作, ...

  3. MyBatis3.2从入门到精通第一章

    第一章一.引言mybatis是一个持久层框架,是apache下的顶级项目.mybatis托管到goolecode下,再后来托管到github下.(百度百科有解释)二.概述mybatis让程序将主要精力 ...

  4. Nova PhoneGap框架 第一章 前言

    Nova PhoneGap Framework诞生于2012年11月,从第一个版本的发布到现在,这个框架经历了多个项目的考验.一直以来我们也持续更新这个框架,使其不断完善.到现在,这个框架已比较稳定了 ...

  5. 第一章 MYSQL的架构和历史

    在读第一章的过程中,整理出来了一些重要的概念. 锁粒度  表锁(服务器实现,忽略存储引擎). 行锁(存储引擎实现,服务器没有实现). 事务的ACID概念 原子性(要么全部成功,要么全部回滚). 一致性 ...

  6. 第一章 Java多线程技能

    1.初步了解"进程"."线程"."多线程" 说到多线程,大多都会联系到"进程"和"线程".那么这两者 ...

  7. 【读书笔记】《编程珠玑》第一章之位向量&位图

    此书的叙述模式是借由一个具体问题来引出的一系列算法,数据结构等等方面的技巧性策略.共分三篇,基础,性能,应用.每篇涵盖数章,章内案例都非常切实棘手,解说也生动有趣. 自个呢也是头一次接触编程技巧类的书 ...

  8. 《JavaScript高级程序设计(第3版)》阅读总结记录第一章之JavaScript简介

    前言: 为什么会想到把<JavaScript 高级程序设计(第 3 版)>总结记录呢,之前写过一篇博客,研究的轮播效果,后来又去看了<JavaScript 高级程序设计(第3版)&g ...

  9. 《Entity Framework 6 Recipes》翻译系列 (1) -----第一章 开始使用实体框架之历史和框架简述

    微软的Entity Framework 受到越来越多人的关注和使用,Entity Framework7.0版本也即将发行.虽然已经开源,可遗憾的是,国内没有关于它的书籍,更不用说好书了,可能是因为EF ...

  10. 《Entity Framework 6 Recipes》翻译系列(2) -----第一章 开始使用实体框架之使用介绍

    Visual Studio 我们在Windows平台上开发应用程序使用的工具主要是Visual Studio.这个集成开发环境已经演化了很多年,从一个简单的C++编辑器和编译器到一个高度集成.支持软件 ...

随机推荐

  1. NDK Jni 开发(1)

    1. 学习地址 http://my.oschina.net/lifj/blog/177087 http://www.cnblogs.com/devinzhang/archive/2012/02/29/ ...

  2. sqlite3基本相关使用

    闲来无事,复习和总结了一下之前学习到的关于sqlite3数据库的相关知识: [1] sqlite3的安装:1.离线安装:sudo dpkg -i *.deb2.在线安装:sudo apt-get in ...

  3. Opencv基础课必须掌握:滑动条做调色盘 -OpenCV步步精深

    滑动条做调色盘 我们来想一下这个程序需要什么,首先需要一个窗口显示一切=.=(︿( ̄︶ ̄)︿废话一样): 说到调色盘除了画板也就是窗口(默认为黑色),调色就要涉及三种颜色 红色Red(我们用R表示), ...

  4. MySQL自定义函数用法详解-复合结构自定义变量/流程控制

    自定义函数 (user-defined function UDF)就是用一个象ABS() 或 CONCAT()这样的固有(内建)函数一样作用的新函数去扩展MySQL. 所以UDF是对MySQL功能的一 ...

  5. LINUX 笔记-top命令

    top命令经常用来监控linux的系统状况,比如cpu.内存的使用. top - :: up day, :, users, load average: 0.00, 0.01, 0.00 Tasks: ...

  6. C++参数传递(01)

    *是取值运算符,对地址使用可以获得地址中储存的数值:对于指针a,*a表示取a中的值 &是地址运算符,对变量使用可以获得该变量的地址. 对于变量b,*b表示取b的地址 别名(引用):主要用于做函 ...

  7. 使用sklearn进行数据挖掘-房价预测(4)—数据预处理

    在使用机器算法之前,我们先把数据做下预处理,先把特征和标签拆分出来 housing = strat_train_set.drop("median_house_value",axis ...

  8. hibernate的session详解

  9. Android 开发笔记___图像视图

    <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...

  10. redhat7 Samba

    1.先安装Samba服务 yum install -y samba samba-client 2.配置文件 vi /etc/samba/smb.conf  --主配置文件 [global]  --全局 ...