<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>
How can we add a time to live property for the LocalRegion1 or the cache defined as above? I would like to completely refresh my cache every 24 hrs and get new data from server. Im using a local cache, which get some data from a server and stores locally.
You can set a time-to-live on a region, by adding a region-ttl node, as stated below:
<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>
In this example, you can set the time-to-live in seconds by using a property named local.region1.ttl
. Of course you can always rename that property or use a literal instead (60 seconds):
<gfe:region-ttl timeout="60" action="DESTROY"/>
Note that the timer will be reset every time you update / add an entry to the region.