2012-12-19 25 views
1
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util" 
    xmlns:gfe="http://www.springframework.org/schema/gemfire" 
    xsi:schemaLocation="http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd 
     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd 
     http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> 

    <util:properties id="gemfire-props"> 
     <prop key="log-level">warning</prop> 
    </util:properties> 

    <gfe:cache properties-ref="gemfire-props" /> 

    <gfe:local-region id="LocalRegion1"> 
     <gfe:cache-listener> 
      <bean 
       class="com.mycompany.util.LoggingCacheListener" /> 
     </gfe:cache-listener> 
    </gfe:local-region> 

</beans> 

我們怎樣才能增加生存時間屬性爲LocalRegion1或如上定義緩存?我想每24小時徹底刷新緩存並從服務器獲取新數據。我使用本地緩存,它從服務器獲取一些數據並存儲在本地。添加時間住物業,以我的緩存

回答

1

您可以設置區域的時間到現場,通過增加一個區域TTL節點,如規定如下:

<gfe:local-region id="LocalRegion1"> 
    <gfe:region-ttl timeout="${local.region1.ttl}" action="DESTROY"/> 
    <gfe:cache-listener> 
     <bean 
      class="com.mycompany.util.LoggingCacheListener" /> 
    </gfe:cache-listener> 
</gfe:local-region>  

在這個例子中,你可以設置時間到現場秒使用名爲local.region1.ttl的屬性。當然,你總是可以重命名屬性或使用文字來代替(60秒):

<gfe:region-ttl timeout="60" action="DESTROY"/> 

注意:計時器將每次更新/添加到區域中的條目都可以重新設置。