hibernate二级只读缓存设置 --oracle 是对sessionFactory而言的
来源:互联网 发布:模拟人生4作弊码mac 编辑:程序博客网 时间:2024/05/21 09:12
配置二级缓存的文件 hibernate.cfg.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN""http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="">
<!-- 配置oracle驱动 -->
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.password">123456</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:orcl</property>
<property name="hibernate.connection.username">scott</property>
<!-- 方言 -->
<property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>
<!-- 输出打印sql语句 -->
<property name="hibernate.show_sql">true</property>
<!-- 配置session的获取方式 currentSession-->
<property name="hibernate.current_session_context_class">thread</property>
<!-- <property name="hibernate.use_sql_comments">true</property>
sql语句格式化输出 -->
<property name="hibernate.format_sql">true</property>
<!-- 是否创建表 没有表-->
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="hibernate.cache.use_second_level_cache">true</property>
<!-- 设置实现二级缓存的实现类 -->
<property name="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</property>
<!-- 注册实体的映射文件 -->
<mapping resource="com/hu/po/HibernateUser.hbm.xml"/>
<!-- 设置启用二级缓存的实现类的只读(查询)缓存 -->
<class-cache usage="read-only" class="com.hu.po.HibernateUser"/>
</hibernate-configuration>
ehcache.xml文件 项目路径
<ehcache>
<diskStore path="./target/tmp"/>
<-- 这些数据是通过压力测试 负荷是运行负荷的一倍时测得的值-->
<defaultCache
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
overflowToDisk="true"
maxElementsOnDisk="10000000"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU"
/>
<!-- maxElementsInMemory Cache中最多允许保存的数据对象的数量 -->
<!-- external=“false” //缓存中对象是否为永久的,如果是,超时设置将被忽略,对象从不过期 -->
<!-- timeToIdleSeconds=“1000” //缓存数据钝化时间(设置对象在它过期之前的空闲时间) -->
<!-- timeToLiveSeconds=“1000” 缓存数据的生存时间(设置对象在它过期之前的生存时间)-->
<!-- overflowToDisk=“false” /> //内存不足时,是否启用磁盘缓存 -->
<!-- memoryStoreEvictionPolicy="LRU" //内存不足时数据对象的清除策略
ehcache中缓存的3种清空策略:
FIFO(first in first out):先进先出
LFU( Less Frequently Used):一直以来最少被使用的。如上面所讲,缓存的元素有一个hit属性,
hit值最小的将会被清出缓存。
LRU(Least Recently Used):最近最少使用的,缓存的元素有一个时间戳,当缓存容量满了 ,
而又需要腾出地方来缓存新的元素的时候,那么现有缓存元素中
时间戳离当前时间最远的元素将被清出缓存。
-->
</ehcache>
文件路径
所需jar包
- hibernate二级只读缓存设置 --oracle 是对sessionFactory而言的
- 说说自己对hibernate一级、二级、查询、缓存的理解。
- hibernate sessionFactory是做什么的,一级缓存二级缓存都是干什么的
- eclipse 文件的相对路径是对project而言
- 设置Hibernate的二级Cache
- hibernate缓存一级和二级的区别
- hibernate的一级缓存session和二级缓存sessionFactory应用解析
- Hibernate的一级缓存Session和二级缓存SessionFactory
- 对指定的表设置只读属性
- 设置文本框是只读
- Hibernate中的sessionFactory是做什么用的?
- Hibernate sessionFactory相关xml设置
- Hibernate的Transaction SessionFactory
- Hibernate 的 SessionFactory接口
- Hibernate的sessionFactory
- 对Oracle 语句缓存设置和JDBC PreparedStatement的试验
- 为什么万兆以太网对城域网而言是新的带宽标准?
- 对你我而言,遇到爱,遇到性,都不稀罕,稀罕的是遇到理解
- 基于How To Tango With Django 1.7的实践(1)
- 1
- 多校联盟#con1 数学题
- 将Excel表格或者CSV文件导入到Mysql中
- spark sql 中出现的问题
- hibernate二级只读缓存设置 --oracle 是对sessionFactory而言的
- [LeetCode]372. Super Pow
- Codeforces #402 (Div. 2) C. Dishonest Sellers
- 输入n个整数,找出其中最小的K个数
- Python3 从HTTP代理网站批量获取代理并筛选
- RAFT 论文中文翻译(1)
- Linux centos7一键安装lamp
- Java 中的悲观锁和乐观锁的实现
- 【摘录】大数据挖掘与知识发现的应用领域