jakarta-jcs-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tim Cronin" <tcro...@interwoven.com>
Subject Setting cache timeout on elements
Date Wed, 31 Aug 2005 19:21:29 GMT
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?


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message