This content has been marked as final.
Show 2 replies
-
1. Re: How to set expiry time for s:cache?
pmuir Nov 24, 2007 2:35 PM (in response to stef5636)You can specify the region into which to cache the data, this region can have an expiration policy associated. Read the JBoss Cache manual for more. s:cache is based on PojoCache.
-
2. Re: How to set expiry time for s:cache?
satellite Nov 25, 2007 4:27 AM (in response to stef5636)I'm using this treecache.xml with success:
<?xml version="1.0" encoding="UTF-8"?> <server> <mbean code="org.jboss.cache.TreeCache" name="jboss.cache:service=TreeCache"> <depends>jboss:service=Naming</depends> <depends>jboss:service=TransactionManager</depends> <!-- Configure the TransactionManager --> <attribute name="TransactionManagerLookupClass"> org.jboss.cache.JBossTransactionManagerLookup </attribute> <!-- Specific eviction policy configurations. --> <attribute name="EvictionPolicyConfig"> <config> <attribute name="wakeUpIntervalSeconds">5</attribute> <!-- Cache wide default --> <region name="/_default_" policyClass="org.jboss.cache.eviction.LRUPolicy"> <!-- This is the maximum number of nodes allowed in this region. --> <!-- 0 denotes no limit. --> <attribute name="maxNodes">0</attribute> <!-- The amount of time a node is not written to or read (in seconds) before the node is swept away. --> <!-- 0 denotes no limit. --> <attribute name="timeToLiveSeconds">0</attribute> <!-- Lifespan of a node (in seconds) regardless of idle time before the node is swept away. --> <!-- 0 denotes no limit. --> <attribute name="maxAgeSeconds">0</attribute> </region> <region name="/5sec" policyClass="org.jboss.cache.eviction.LRUPolicy"> <attribute name="maxNodes">0</attribute> <attribute name="timeToLiveSeconds">0</attribute> <attribute name="maxAgeSeconds">5</attribute> </region> </config> </attribute> </mbean> </server>
Code for testing:<table border="1"> <tr> <td><b>Short term cache ('/5sec'):</b></td> <td> <s:cache region="/5sec" key="now" enabled="true"> <h:outputText value="#{form.info.now()}" /> </s:cache> </td> </tr> <tr> <td><b>Long term cache ('/forever'):</b></td> <td> <s:cache region="/forever" key="now" enabled="true"> <h:outputText value="#{form.info.now()}" /> </s:cache> </td> </tr> </table>