Issue Details (XML | Word | Printable)

Key: JCS-16
Type: Bug Bug
Status: Open Open
Priority: Minor Minor
Assignee: Aaron Smuts
Reporter: Peter Lawrey
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
JCS

The jcs.default.cacheattributes.MaxObjects does not work as expected.

Created: 13/Feb/07 11:48 AM   Updated: 25/Mar/08 03:34 PM
Component/s: Composite Cache
Affects Version/s: jcs-1.3
Fix Version/s: jcs-1.4-dev

Time Tracking:
Not Specified

Environment: Windows

Labels:


 Description  « Hide
Using code based on JSCThrashTest ..
jcs.default=
jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.default.cacheattributes.MaxObjects=10000
jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache

If I add 10,000 elements the getListSize() return 9,998 elements.
If I change the MaxObjects to 10002 and add 15 K elements the getListSize() return 10,000 elements.

Is there a good reason I need to add 2 to MaxObjects?
I have scanned the cache and found there is actually 10000 elements when MaxObject is set to 10002

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Aaron Smuts added a comment - 16/Mar/07 12:27 AM
The memory cache is buffering items to disk when the max is reached. It's set to move 2 or 3 at once. When the max is reached, it moves 2 or 3 (I need to check).

Thomas Vandahl made changes - 11/Jun/07 06:17 PM
Field Original Value New Value
Affects Version/s jcs-1.2.7.9.2 [ 12312062 ]
Fix Version/s jcs-1.4-dev [ 12312535 ]
Affects Version/s jcs-1.3 [ 12312534 ]
Juan Vaccarezza added a comment - 25/Mar/08 03:34 PM
I inspected the code of the LRUMemoryCache and i've found that on the line 126 it checks if the max object properties has been reached, and if so, cleans the cache. I guess that this is wrong cause it has to check if the amount of stored object has exccedes the max objects configured.
Changin this lines

// If the element limit is reached, we need to spool

if ( size < this.cattr.getMaxObjects() )
{
     return;
}

for these:

if ( size <= this.cattr.getMaxObjects() )
{
     return;
}

should make the trick.