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時間ごとにキャッシュを完全に更新し、サーバーから新しいデータを取得したいと思います。サーバーからデータを取得してローカルに保存するローカルキャッシュを使用しています。

4

1 に答える 1

1

以下に示すように、region-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"/>

リージョンにエントリを更新/追加するたびに、タイマーがリセットされることに注意してください。

于 2012-12-20T21:11:58.583 に答える