HibernateEhcacheJgroups - 基于Annotation的集群缓存配置
2014-04-01 21:35
429 查看
一、版本相关
ehcache-jgroupsreplication-1.7.jar
jgroups-3.4.1.Final.jar
ehcache-core-2.6.5.jar
hibernate3.6.10.Final.jar
二、EhCache ehcache.xml配置
三、Hibernate applicationContext.xml配置
ehcache-jgroupsreplication-1.7.jar
jgroups-3.4.1.Final.jar
ehcache-core-2.6.5.jar
hibernate3.6.10.Final.jar
二、EhCache ehcache.xml配置
<?xml version="1.0" encoding="UTF-8"?> <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="true" monitoring="autodetect" dynamicConfig="true"> <diskStore path="E:/WS/temp/ehcahe" /> <cacheManagerPeerProviderFactory class="net.sf.ehcache.distribution.jgroups.JGroupsCacheManagerPeerProviderFactory" properties="connect=UDP(mcast_addr=230.0.0.1;mcast_port=45566;tos=32;mcast_recv_buf_size=120000;loopback=true; mcast_send_buf_size=80000;discard_incompatible_packets=true;max_bundle_size=64K;max_bundle_timeout=30; ip_ttl=32;enable_bundling=true;enable_diagnostics=true;thread_naming_pattern=cl;timer.min_threads=4; timer_type=new;timer.max_threads=10;timer.keep_alive_time=3000;timer.queue_max_size=500;thread_pool.enabled=true; thread_pool.min_threads=2;thread_pool.max_threads=8;thread_pool.keep_alive_time=5000;oob_thread_pool.keep_alive_time=5000; thread_pool.queue_enabled=true;thread_pool.queue_max_size=10000;thread_pool.rejection_policy=discard; oob_thread_pool.enabled=true;oob_thread_pool.min_threads=1;oob_thread_pool.max_threads=8; oob_thread_pool.queue_enabled=false;oob_thread_pool.queue_max_size=100;oob_thread_pool.rejection_policy=Run): PING(timeout=2000;num_initial_members=6): MERGE2(min_interval=5000;max_interval=10000): VERIFY_SUSPECT(timeout=1500): pbcast.NAKACK(use_mcast_xmit=true;discard_delivered_msgs=true;retransmit_timeout=1200): UNICAST(timeout=1200): pbcast.STABLE(desired_avg_gossip=20000;stability_delay=1000;max_bytes=4M): pbcast.GMS(print_local_addr=true;join_timeout=3000;view_bundling=true): FRAG2(frag_size=60K)" propertySeparator="::"/> <defaultCache maxEntriesLocalHeap="10000" eternal="false" overflowToDisk="true" timeToIdleSeconds="600" timeToLiveSeconds="600" diskPersistent="false"> <cacheEventListenerFactory class="net.sf.ehcache.distribution.jgroups.JGroupsCacheReplicatorFactory" properties="replicateAsynchronously=true, replicatePuts=true, replicateUpdates=true, replicateUpdatesViaCopy=true, replicateRemovals=true, asynchronousReplicationIntervalMillis=200" /> <bootstrapCacheLoaderFactory class="net.sf.ehcache.distribution.jgroups.JGroupsBootstrapCacheLoaderFactory" properties="bootstrapAsynchronously=true, maximumChunkSizeBytes=50000000"/> </defaultCache> <cache name="org.hibernate.cache.StandardQueryCache" maxElementsInMemory="10000" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="600" overflowToDisk="true"> <cacheEventListenerFactory class="net.sf.ehcache.distribution.jgroups.JGroupsCacheReplicatorFactory" properties="replicateAsynchronously=true, replicatePuts=true,replicateUpdates=true, replicateUpdatesViaCopy=true,replicateRemovals=true,asynchronousReplicationIntervalMillis=200" /> <bootstrapCacheLoaderFactory class="net.sf.ehcache.distribution.jgroups.JGroupsBootstrapCacheLoaderFactory" properties="bootstrapAsynchronously=true, maximumChunkSizeBytes=50000000"/> </cache> <cache name="org.hibernate.cache.UpdateTimestampsCache" maxElementsInMemory="10000" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="600" overflowToDisk="true"> <cacheEventListenerFactory class="net.sf.ehcache.distribution.jgroups.JGroupsCacheReplicatorFactory" properties="replicateAsynchronously=true, replicatePuts=true, replicateUpdates=true, replicateUpdatesViaCopy=true,replicateRemovals=true,asynchronousReplicationIntervalMillis=200" /> <bootstrapCacheLoaderFactory class="net.sf.ehcache.distribution.jgroups.JGroupsBootstrapCacheLoaderFactory" properties="bootstrapAsynchronously=true, maximumChunkSizeBytes=50000000"/> </cache> </ehcache>
三、Hibernate applicationContext.xml配置
<context:component-scan base-package="com.clusterehcache" /> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource"> <ref bean="dataSource"/> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.format_sql">true</prop> <prop key="hibernate.cache.use_second_level_cache">true</prop> <prop key="hibernate.cache.use_query_cache">true</prop> <prop key="hibernate.cache.region.factory_class">net.sf.ehcache.hibernate.EhCacheRegionFactory</prop> </props> </property> <property name="packagesToScan"> <list> <value>com.clusterehcache.centity</value> </list> </property> </bean>四、Entity配置
@Entity @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) public class User { …… }
相关文章推荐
- HibernateEhcacheJgroups - 基于Annotation的集群缓存配置
- HibernateEhcacheJgroups - 基于Annotation的集群缓存配置
- Hibernate配置EhCache缓存之annotation注解
- Hibernate二级缓存简述及基于Spring4,Hibernate5,Ehcache3的二级缓存配置
- Hibernate之Hibernate+EHCache配置二级缓存实战
- Hibernate 的 二级缓存——ehcache配置文件
- spring与hibernate整合配置基于Annotation注解方式管理实务
- 基于注解形式的hibernate二级缓存的使用(ehcache)
- 在 JPA、Hibernate 和 Spring 中配置 Ehcache 缓存
- ehCache集群JGroups方式配置
- Hibernate 二级缓存 ehcache.xml 的相关配置的几点问题
- Hibernate JPA 中配置Ehcache二级缓存
- spring4-hibernate4-二级缓存ehcache配置
- Spirng3基于注解(annotation)整合ehcache 使用页面缓存、对象缓存
- Hibernate中ehcache二级缓存配置方法
- Spring3与Hibernate4整合,Spring中配置Hibernate基于XML和annotation的sessionFactory方式。
- Hibernate的缓存技术EhCache的配置
- Hibernate4.1.4配置二级缓存EHCache步骤
- Spirng3基于注解(annotation)整合ehcache 使用页面缓存、对象缓存
- 基于注解形式的hibernate二级缓存的使用(ehcache)