RE: [coldbox:8619] Re: CacheBox configuration question on ObjectDefaultTimeout

However, it doesn’t make any sense to me on why if I cache 4 items
initial w/a maxObjects to 3 that none would remain in cache. It would
seem like some of the items would remain cached.

But some of the items did stay in the cache on the first request. It was when you started refreshing that the cache started evicting items. I think evicted items that have not yet been reaped still count towards your total number of items in the cache.

What happens if you wait 2 minutes before each refresh or use the reap all button in cache box?

~Brad

Few things,

last access timeout is used by the reaping which happens according to the frequency you set. If the object has not been used in that X amount of time, then it is marked to be removed in the next iteration but makes the object mark as dead. The timeout is the overall life of the object.

At one point in time the cache can have more objects than the max object property because it can contain objects that never expire (0 timeouts) and also objects that have been marked as expired or dead. The cache catches up on the next reaping frequencies to cleanse itself out. If you use the concurrent soft reference store even better, because the real object has been wiped and what remains is the shell representing it.

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Luis,

It doesn't seem like the behavior I described matched what you said.

I'm using the following cache provider:

<Cache name="shorty" provider="cachebox.system.cache.providers.CacheBoxProvider">
  <Properties
    objectDefaultTimeout="5"
    objectDefaultLastAccessTimeout="2"
    useLastAccessTimeouts="true"
    reapFrequency="2"
    freeMemoryPercentageThreshold="0"
    maxObjects="3"
    evictionPolicy="LRU"
    evictCount="1"
    objectStore="ConcurrentStore"
    coldboxEnabled="false"
      />
</Cache>

I'm attempting to cache 4 items:

cache.set("item1", data1, 11, 10);
cache.set("item2", data2, 10, 9);
cache.set("item3", data3, 9, 8);
cache.set("item4", data4, 3, 2);

When this code runs, all 4 items are created in cache and are reporting in the monitoring tool as being "alive".

However, if I now run:

cache.lookup("item1"); // return false;
cache.lookup("item2"); // return false;
cache.lookup("item3"); // return false;
cache.lookup("item4"); // return false;

Each lookup line will return false. I would expect items 1-3 to remain in the cache and item 4 being dumped. I certainly wouldn't expect all of the objects to be reported as not existing in the cache.

I can send you a template which allow you to select how many items to cache so you can see the behavior. It gets even weirder and more unpredictable when I start w/3 items in cache, then add a 4th and keep trying to access the cache. Sometime all the items are invalidated and re-loaded. Sometimes one or two of the items are retrieved from cache.

-Dan

Brad,

But some of the items did stay in the cache on the first request. It was
when you started refreshing that the cache started evicting items. I
think evicted items that have not yet been reaped still count towards
your total number of items in the cache.

On the first hit if you cache more than the maxObjects, then all the objects are cached. However, if you refresh the page all of the items get add to the cache *again* because the call to lookup() returns false for every item. So, it seems like lookup() is not properly able to determine items that should be evicted.

What happens if you wait 2 minutes before each refresh or use the reap
all button in cache box?

Waiting does not seem to make a difference--no matter how long I wait.

-Dan

Post the sample, but we run extensive tests on the cache and these are the basics of its expiration, reaping and collection so please send me somethign I can try out.

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Luis,

I sent you an offline message w/the source (since Google Groups seems
to strip attachments.)

Did you have a chance to look at it?

Thanks,
Dan