3 Replies Latest reply on Feb 24, 2009 4:24 AM by manik

    ExpirationAlgorithm - Eviction Policy

    thangamani_r

      Hi ,

      I need an example to configure ExpirationAlgorithm correctly using config file .

      Right now I am using

      <eviction wakeUpInterval="500">
      <default algorithmClass="org.jboss.cache.eviction.ExpirationAlgorithm" eventQueueSize="100000">
       <property name="maxNodes" value="500" />
       <property name="expirationKeyName" value="Opportunity" />
       </default>
       </eviction>


      But with this I get the following message

      WARN [ExpirationAlgorithm] No expiration key 'Opportunity' for Nod
      e: /Opportunity/key1


        • 1. Re: ExpirationAlgorithm - Eviction Policy
          manik

          For each node in the region you need to add an attribute which uses ExpirationAlgorithmConfig.EXPIRATION_KEY as key and a long which specifies a time-to-live for that node.

          See ExpirationAlgorithm javadocs.

          • 2. Re: ExpirationAlgorithm - Eviction Policy
            thangamani_r

            Hi Manik,
            The javadoc mentions about expiration config being set programatically.

            Cache cache;
             Fqn fqn1 = Fqn.fromString("/node/1");
             Long future = new Long(System.currentTimeMillis() + 2000);
             cache.put(fqn1, ExpirationConfiguration.EXPIRATION_KEY, future);
             cache.put(fqn1, "foo");
             assertTrue(cache.get(fqn1) != null);
            
             Thread.sleep(5000); // 5 seconds
             assertTrue(cache.get(fqn1) == null);


            I would like to know if it is possible to set it programatically only ?

            or can we set it through the config file. What would be the setting in the config file. Is there any example for the config file setting?

            Even the programatic approach as mentioned in the docs does not evict the node..

            • 3. Re: ExpirationAlgorithm - Eviction Policy
              manik

              Programmatically only, and it needs to be in a region that has the expiration eviction algorithm configured.