---
title: "jbosscache1.4 invalidation模式下put会导致发送invalidation的问题"
author: "eddie"
date: "2007-02-02T18:10:11Z"
tags: []
categories: ["企业架构"]
slug: "jbosscache1-4-invalidation-put-invalidation"
draft: false
lastmod: "2007-02-02T18:10:11Z"
id: 51887
url: "https://eddie.iteye.com/blog/51887"
---

我们在项目中使用jbosscache来做分布式缓存部分数据库数据。打算用INVALIDATION\_SYNC来将remove的数据失效掉，

但令人失望的是，我们在put数据的时候，发现它也会广播invalidation消息，导致数据失效。这样的结果是，只有1台服务器有

缓存数据，其他服务器从数据库取到相同数据put到缓存时，就会导致其他服务器缓存失效，但这个操作实际上没有修改数据。

实在是不合理。可能是我们的使用方式有问题，或者有其他配置方法，请有这方面的朋友能帮助下，谢谢！

 

配置文件如下（就是标准的那个invalidationSync-service.xml文件）：

&lt;server&gt;&lt;/server&gt;

   &lt;classpath archives="jboss-cache.jar, jgroups.jar" codebase="./lib"&gt;&lt;/classpath&gt;

    
    
  

   &lt;mbean code="org.jboss.cache.CacheImpl"&gt;&lt;/mbean&gt;          name="jboss.cache:service=TreeCache"&gt;

      &lt;depends&gt;&lt;/depends&gt;jboss:service=Naming  
      &lt;depends&gt;&lt;/depends&gt;jboss:service=TransactionManager

       
      &lt;attribute name="TransactionManagerLookupClass"&gt;&lt;/attribute&gt;org.jboss.cache.DummyTransactionManagerLookup

       
      &lt;attribute name="IsolationLevel"&gt;&lt;/attribute&gt;REPEATABLE\_READ

       
      &lt;attribute name="CacheMode"&gt;&lt;/attribute&gt;INVALIDATION\_SYNC

       
      &lt;attribute name="UseReplQueue"&gt;&lt;/attribute&gt;false

       
      &lt;attribute name="ReplQueueInterval"&gt;&lt;/attribute&gt;0

       
      &lt;attribute name="ReplQueueMaxElements"&gt;&lt;/attribute&gt;0

       
      &lt;attribute name="ClusterName"&gt;&lt;/attribute&gt;JBossCache-Cluster

       
     

       
      &lt;attribute name="ClusterConfig"&gt;&lt;/attribute&gt;  
         &lt;config&gt;&lt;/config&gt;  
             
             
            &lt;udp mcast\_addr="228.1.2.3" mcast\_port="48866"&gt;&lt;/udp&gt;                 ip\_ttl="64" ip\_mcast="true"  
                 mcast\_send\_buf\_size="150000" mcast\_recv\_buf\_size="80000"  
                 ucast\_send\_buf\_size="150000" ucast\_recv\_buf\_size="80000"  
                 loopback="false"/&gt;  
            &lt;ping num\_initial\_members="3" timeout="2000"&gt;&lt;/ping&gt;                   up\_thread="false" down\_thread="false"/&gt;  
            &lt;merge2 max\_interval="20000" min\_interval="10000"&gt;&lt;/merge2&gt;  
             
            &lt;fd\_sock&gt;&lt;/fd\_sock&gt;  
            &lt;verify\_suspect timeout="1500"&gt;&lt;/verify\_suspect&gt;                            up\_thread="false" down\_thread="false"/&gt;  
            &lt;pbcast.nakack retransmit\_timeout="600,1200,2400,4800" gc\_lag="50"&gt;&lt;/pbcast.nakack&gt;                            max\_xmit\_size="8192" up\_thread="false" down\_thread="false"/&gt;  
            &lt;unicast timeout="600,1200,2400" down\_thread="false"&gt;&lt;/unicast&gt;  
            &lt;pbcast.stable desired\_avg\_gossip="20000"&gt;&lt;/pbcast.stable&gt;                            up\_thread="false" down\_thread="false"/&gt;  
            &lt;frag frag\_size="8192"&gt;&lt;/frag&gt;                  down\_thread="false" up\_thread="false"/&gt;  
            &lt;pbcast.gms join\_retry\_timeout="2000" join\_timeout="5000"&gt;&lt;/pbcast.gms&gt;                         shun="true" print\_local\_addr="true"/&gt;  
            &lt;pbcast.state\_transfer down\_thread="true" up\_thread="true"&gt;&lt;/pbcast.state\_transfer&gt;  
          
     

       
      &lt;attribute name="FetchInMemoryState"&gt;&lt;/attribute&gt;true

       
      &lt;attribute name="InitialStateRetrievalTimeout"&gt;&lt;/attribute&gt;15000

       
      &lt;attribute name="SyncReplTimeout"&gt;&lt;/attribute&gt;15000

       
      &lt;attribute name="LockAcquisitionTimeout"&gt;&lt;/attribute&gt;10000

       
      &lt;attribute name="EvictionPolicyClass"&gt;&lt;/attribute&gt;

       
      &lt;attribute name="UseRegionBasedMarshalling"&gt;&lt;/attribute&gt;false