jakarta-jcs-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tim Cronin" <tcro...@interwoven.com>
Subject RE: Setting cache timeout on elements
Date Wed, 31 Aug 2005 19:29:05 GMT
Ok answered my own question:

jcs.default.elementattributes.IsEternal=false

-----Original Message-----
From: Tim Cronin [mailto:tcronin@interwoven.com] 
Sent: Wednesday, August 31, 2005 2:21 PM
To: JCS Users List
Subject: Setting cache timeout on elements

I need to be able to set the cache timeout on individual elements.

 

I created a simple function to test with:

  public void put(Object key, Object value, long ttl)

  {

    try

    {

      mCache.put(key, value);

 

      IElementAttributes iea = mCache.getElementAttributes(key);

 

      iea.setMaxLifeSeconds(ttl);

 

      System.out.println(mCache.getElementAttributes(key));

    }

    catch (CacheException e)

    {

      throw new RuntimeException("Failed add to cache " + key, e);

    }

  }

 

Then I'm testing with the following:

     m.put("key", "value", 30);

 

      long time = System.currentTimeMillis();

      while (m.get("key") != null)

      {

        try

        {

          Thread.sleep(500);

          System.err.print(".");

        }

        catch (InterruptedException e)

        {

          System.err.println("interupted...");

        }

      }

      System.out.println();

      System.out.println(((System.currentTimeMillis() - time)/1000));

 

 

 

But the loop never exits. Am I doing something wrong?


---------------------------------------------------------------------
To unsubscribe, e-mail: jcs-users-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jcs-users-help@jakarta.apache.org


Mime
View raw message