> 
> I thought idle time at the element level was long gone.  
> Hmmn.  There is
> max idle time at the region, which is for the memory shrinker.  I'll
> have to look into it.
> 
> http://jakarta.apache.org/jcs/RegionProperties.html

> > 
> > Ard Schrijvers suggested changing use of "jcs" below to "cache"
> because he
> > thought "jcs" just had default configuration.  This is wrong.  I
> stepped
> > through the code and saw that when the elements were being 
> put in the
> > cache they were put in with an idle time of 5 seconds as I setup in
> the
> > setupProperties() method, not with a default value of idle time.
> Anyway,
> > the "cache" object doesn't have get() and put() methods so 
> it can't be

Sry, I mailed it a little wrong:

can you try with 

GroupCacheAccess cache = new GroupCacheAccess(mgr.getCache("BugTest"));

Now, cache can put and get, and I am curious wether idle time is now honoured

Regards Ard

> > used directly for storing information in JCS.  I access the "cache"
> object
> > directly only to be able to retrieve the element attributes 
> associated
> > with the cache (getElementAttributes) and the count of expired items
> > (getMissCountExpired).
> > 
> > It looks to me like there is a bug in JCS as I originally thought.
> > Stepping in the code, when it tries to get the item from 
> the cache (in
> > LRUMemoryCache.get()) it sets the last access time to now 
> which messes
> up
> > the later checking of how long the item has been idle.  I think the
> code
> > that is getting the item from the cache should call
> > LRUMemoryCache.getQuiet() instead of LRUMemoryCache.get().  
> That code
> is
> > in CompositeCache.get().  I'm not sure what other effects calling
> > LRUMemoryCache.getQuiet() instead of LRUMemoryCache.get() will have
> > though.
> > 
> > 
> > 
> > 
> > 
> > 
> > -----Original Message-----
> > 
> > From: Ard Schrijvers [mailto:[EMAIL PROTECTED]
> > To: jcs-users@jakarta.apache.org
> > 
> > Subject: RE: Possible bug in JCS with IdleTime element attribute
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > >
> > 
> > 
> > > I think I may have found a bug in JCS with regards
> > to the
> > 
> > 
> > > IdleTime element attribute.  Either that
> > 
> > 
> > > or I don't understand how this setting works.
> > 
> > 
> > 
> > 
> > 
> > I thin you have a bug in your test...
> > 
> > 
> > 
> > 
> > 
> > >
> > 
> > 
> > > import junit.framework.TestCase;
> > 
> > 
> > >
> > 
> > 
> > > public class TestMissCountExpiredBug extends
> > TestCase
> > 
> > 
> > > {
> > 
> > 
> > >   public void
> > testSomething()
> > 
> > 
> > >     throws
> > Exception
> > 
> > 
> > >   {
> > 
> > 
> > >     // setup
> > JCS
> > 
> > 
> > >
> > CompositeCacheManager mgr =
> > 
> > 
> > > CompositeCacheManager.getUnconfiguredInstance();
> > 
> > 
> > >
> > mgr.configure( setupProperties() );
> > 
> > 
> > >
> > 
> > 
> > >     // get access to bug test cache region
> > 
> > 
> > >     JCS jcs =
> > JCS.getInstance( "BugTest" );
> > 
> > 
> > >
> > CompositeCache cache = mgr.getCache( "BugTest" );
> > 
> > 
> > 
> > 
> > 
> > now, cache is the cache you get from your configured
> > CompositeCacheManager. I think, your jcs has just default
> configuration,
> > because I do not see where it is configured..?
> > 
> > 
> > 
> > 
> > 
> > If you replace jcs below, with cache, you probably will
> > see, everything works just fine,
> > 
> > 
> > 
> > 
> > 
> > Regards Ard
> > 
> > 
> > 
> > 
> > 
> > >
> > 
> > 
> > >     // put
> > five items in cache
> > 
> > 
> > >     for ( int
> > i = 0; i < 5; i++ )
> > 
> > 
> > >     {
> > 
> > 
> > >       String
> > key = "key" + i;
> > 
> > 
> > >       String
> > value = "value" + i;
> > 
> > 
> > >       jcs.put(
> > key, value );
> > 
> > 
> > >     }
> > 
> > 
> > >
> > 
> > 
> > >     // sleep
> > for twice the length of the max idle time of
> > 
> > 
> > > items in the cache
> > 
> > 
> > >     // region
> > 
> > 
> > >
> > IElementAttributes attrs = cache.getElementAttributes();
> > 
> > 
> > >     long
> > idleTimeSeconds = attrs.getIdleTime();
> > 
> > 
> > >
> > assertEquals( 5L, idleTimeSeconds );
> > 
> > 
> > >
> > System.out.println( "idle time seconds=" + idleTimeSeconds );
> > 
> > 
> > >     long
> > sleepTime = 1000 * 2 * idleTimeSeconds;
> > 
> > 
> > >
> > System.out.println( "sleeping for " + sleepTime
> > 
> > 
> > >       + "
> > millis to allow cache elements to be flagged as
> > 
> > 
> > > idle for too long" );
> > 
> > 
> > >
> > Thread.sleep( sleepTime );
> > 
> > 
> > >
> > 
> > 
> > >     // try to
> > access the five items - they should have
> > 
> > 
> > > expired so this should
> > 
> > 
> > >     // fail
> > 
> > 
> > >     for ( int
> > i = 0; i < 5; i++ )
> > 
> > 
> > >     {
> > 
> > 
> > >       String
> > key = "key" + i;
> > 
> > 
> > >       Object
> > value = jcs.get( key );
> > 
> > 
> > >       if (
> > value != null )
> > 
> > 
> > >       {
> > 
> > 
> > >
> > System.out.println( "found a value for key " + key +
> > 
> > 
> > > ": " + value );
> > 
> > 
> > >       }
> > 
> > 
> > >     }
> > 
> > 
> > >
> > 
> > 
> > >     // check
> > miss count expired - should be five
> > 
> > 
> > >     int
> > missCountExpired = cache.getMissCountExpired();
> > 
> > 
> > >
> > System.out.println( "miss count expired: " + missCountExpired
> > );
> > 
> > 
> > >
> > assertEquals( 5, missCountExpired );
> > 
> > 
> > >   }
> > 
> > 
> > >
> > 
> > 
> > >   private
> > Properties setupProperties()
> > 
> > 
> > >   {
> > 
> > 
> > >     Properties
> > answer = new Properties();
> > 
> > 
> > >
> > 
> > 
> > >     //
> > defaults
> > 
> > 
> > >
> > answer.setProperty( "jcs.default", "" );
> > 
> > 
> > >     answer.setProperty(
> > "jcs.default.cacheattributes",
> > 
> > 
> > >
> > "org.apache.jcs.engine.CompositeCacheAttributes" );
> > 
> > 
> > >
> > answer.setProperty(
> > 
> > 
> > >
> > "jcs.default.cacheattributes.MemoryCacheName",
> > 
> > 
> > >
> > "org.apache.jcs.engine.memory.lru.LRUMemoryCache" );
> > 
> > 
> > >
> > answer.setProperty(
> > 
> > 
> > > "jcs.default.cacheattributes.MaxObjects",
> > "100000" );
> > 
> > 
> > >
> > 
> > 
> > >     // bug
> > test region - elements won't go to disk, but
> > 
> > 
> > > should be marked as expired after five seconds of
> > non-use
> > 
> > 
> > >
> > answer.setProperty( "jcs.region.BugTest", "" );
> > 
> > 
> > >
> > answer.setProperty( "jcs.region.BugTest.cacheattributes",
> > 
> > 
> > >
> > "org.apache.jcs.engine.CompositeCacheAttributes" );
> > 
> > 
> > >
> > answer.setProperty(
> > 
> > 
> > >
> > "jcs.region.BugTest.cacheattributes.MemoryCacheName",
> > 
> > 
> > >
> > "org.apache.jcs.engine.memory.lru.LRUMemoryCache" );
> > 
> > 
> > >
> > answer.setProperty(
> > 
> > 
> > >
> > "jcs.region.BugTest.cacheattributes.MaxObjects", "1000" );
> > 
> > 
> > >
> > answer.setProperty(
> > 
> > 
> > >
> > "jcs.region.BugTest.cacheattributes.UseMemoryShrinker",
> > "false" );
> > 
> > 
> > >
> > answer.setProperty(
> > 
> > 
> > > "jcs.region.BugTest.elementattributes",
> > 
> > 
> > > "org.apache.jcs.engine.ElementAttributes"
> > );
> > 
> > 
> > >
> > answer.setProperty(
> > 
> > 
> > >
> > "jcs.region.BugTest.elementattributes.IsEternal", "false"
> > );
> > 
> > 
> > >
> > answer.setProperty(
> > 
> > 
> > >
> > "jcs.region.BugTest.elementattributes.IdleTime", "5" );
> > 
> > 
> > >
> > 
> > 
> > >     return
> > answer;
> > 
> > 
> > >   }
> > 
> > 
> > > }
> > 
> > 
> > >
> > 
> > 
> > >
> > 
> > 
> > >
> > 
> > 
> > >
> > 
> > 
> > >
> > 
> > 
> > >
> > 
> > 
> > >
> > 
> > 
> > >
> > ______________________________________________________________
> > 
> > 
> > > ______________________
> > 
> > 
> > > Now that's room service!  Choose from over 150,000 hotels
> > 
> > 
> > > in 45,000 destinations on Yahoo! Travel to find your
> > fit.
> > 
> > 
> > > http://farechase.yahoo.com/promo-generic-14795097
> > 
> > 
> > >
> > 
> > 
> > >
> > 
> ---------------------------------------------------------------------
> > 
> > 
> > > To unsubscribe, e-mail:
> > [EMAIL PROTECTED]
> > 
> > 
> > > For additional commands, e-mail:
> > [EMAIL PROTECTED]
> > 
> > 
> > >
> > 
> > 
> > >
> > 
> > 
> > 
> > 
> > 
> > 
> ---------------------------------------------------------------------
> > 
> > 
> > To unsubscribe, e-mail:
> > [EMAIL PROTECTED]
> > 
> > 
> > For additional commands, e-mail:
> > [EMAIL PROTECTED]
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> >
> ______________________________________________________________
> __________
> __
> > __________
> > Do you Yahoo!?
> > Everyone is raving about the all-new Yahoo! Mail beta.
> > http://new.mail.yahoo.com
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to