使用JBossCache作为Hibernate的二级缓存

这个是最近的工作成果,使用JBossCache作为Hibernate的二级缓存,因为JBossCache支持Transactional的缓存策略(Strategy),而且支持Cluster,Cluster还支持Invalidation的方式,比Replication方式更好,对两种方式同时支持同步和异步,还有其他很多特性,比OSCache好得多。
由于我们是把Hibernate作为服务配置的,所以CacheProviderClass使用的是org.jboss.hibernate.cache.DeployedTreeCacheProvider,需要另外一个MBean进行TreeCache的配置:
<mbean code="org.jboss.cache.TreeCache" name="jboss.cache:service=HibernateTreeCache">
<depends>jboss:service=Naming</depends>
<depends>jboss:service=TransactionManager</depends>
<attribute name="TransactionManagerLookupClass">org.jboss.cache.JBossTransactionManagerLookup</attribute>
<attribute name="EvictionPolicyConfig">
            <config>
                <attribute name="wakeUpIntervalSeconds">10</attribute>
                <region name="/_default_" policyClass="org.jboss.cache.eviction.LRUPolicy">
                    <attribute name="maxNodes">5000</attribute>
                    <attribute name="timeToIdleSeconds">300</attribute>
                </region>
            </config>
</attribute>
<attribute name="NodeLockingScheme">OPTIMISTIC</attribute>
<attribute name="IsolationLevel">REPEATABLE_READ</attribute>
<attribute name="CacheMode">INVALIDATION_ASYNC</attribute>
<attribute name="ClusterName">HibernateInvalidatedReplicatedCache</attribute>
<attribute name="LockAcquisitionTimeout">15000</attribute>
    <attribute name="ClusterConfig">
      <config>
        <UDP mcast_addr="101.101.101.101"
             mcast_port="55588"
             ucast_recv_buf_size="20000000"
             ucast_send_buf_size="640000"
             mcast_recv_buf_size="25000000"
             mcast_send_buf_size="640000"
             loopback="false"
             max_bundle_size="64000"
             max_bundle_timeout="30"
             use_incoming_packet_handler="true"
             use_outgoing_packet_handler="true"
             ip_ttl="${jgroups.mcast.ip_ttl:2}"
             down_thread="false" up_thread="false"
             enable_bundling="true"/>
        <PING timeout="2000"
              down_thread="false" up_thread="false" num_initial_members="3"/>
        <MERGE2 max_interval="100000"
                down_thread="false" up_thread="false" min_interval="20000"/>
        <FD_SOCK down_thread="false" up_thread="false"/>
        <FD shun="true" up_thread="false" down_thread="false"
            timeout="20000" max_tries="5"/>
        <VERIFY_SUSPECT timeout="1500"
                        up_thread="false" down_thread="false"/>
        <pbcast.NAKACK max_xmit_size="60000"
                       use_mcast_xmit="false" gc_lag="50"
                       retransmit_timeout="300,600,1200,2400,4800"
                       down_thread="false" up_thread="false"
                       discard_delivered_msgs="true"/>
        <UNICAST timeout="300,600,1200,2400,3600"
                 down_thread="false" up_thread="false"/>
        <pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"
                       down_thread="false" up_thread="false"
                       max_bytes="400000"/>
        <pbcast.GMS print_local_addr="true" join_timeout="3000"
                    down_thread="false" up_thread="false"
                    join_retry_timeout="2000" shun="true"/>
        <FC max_credits="2000000" down_thread="false" up_thread="false"
            min_threshold="0.10"/>
        <FRAG2 frag_size="60000" down_thread="false" up_thread="false"/>
        <pbcast.STATE_TRANSFER down_thread="false" up_thread="false"/>
      </config>
    </attribute>
</mbean>


作者: 解惑/Cherami
原载: 使用JBossCache作为Hibernate的二级缓存
版权所有。转载时必须以链接形式注明作者和原始出处及本声明。
分类: Java
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值