[ https://issues.apache.org/jira/browse/JCS-60?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12723616#action_12723616 ]
Aaron Smuts commented on JCS-60: -------------------------------- I wrote a test to verify the bug. I fixed it. /** * Verify that the old slot gets in the recycle bin. * <p> * @throws IOException */ public void testProcessUpdate_SameKeyBiggerSize() throws IOException { // SETUP String cacheName = "testProcessUpdate_SameKeyBiggerSize"; IndexedDiskCacheAttributes cattr = new IndexedDiskCacheAttributes(); cattr.setCacheName( cacheName ); cattr.setMaxKeySize( 100 ); cattr.setDiskPath( "target/test-sandbox/IndexDiskCacheUnitTest" ); IndexedDiskCache diskCache = new IndexedDiskCache( cattr ); String key = "myKey"; String value = "myValue"; String value2 = "myValue2"; ICacheElement ce1 = new CacheElement( cacheName, key, value ); // DO WORK diskCache.processUpdate( ce1 ); long fileSize1 = diskCache.getDataFileSize(); // DO WORK ICacheElement ce2 = new CacheElement( cacheName, key, value2 ); diskCache.processUpdate( ce2 ); ICacheElement result = diskCache.processGet( key ); // VERIFY assertNotNull( "Should have a result", result ); long fileSize2 = diskCache.getDataFileSize(); assertTrue( "File should be greater.", fileSize1 < fileSize2 ); int binSize = diskCache.getRecyleBinSize(); assertEquals( "Should be one in the bin.", 1, binSize ); } > Disk cache grows unnecessarily > ------------------------------ > > Key: JCS-60 > URL: https://issues.apache.org/jira/browse/JCS-60 > Project: JCS > Issue Type: Bug > Components: Indexed Disk Cache > Reporter: Alexander Sofronov > Assignee: Aaron Smuts > > I'm using JCS cache in UPDATE mode and I found that disk cache may grow when > adding the cache entries with the same key but larger value. > For example, > cache.put("key", "value"); > cache.put("key", "value1"); > cache.put("key", "value12"); > After that I see that *.data file contains all 3 entries. And the cache is > not optimized at shutdown even when isShutdownOptimizationEnabled is set to > true. > I found a workaround for this - delete the key before writing. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. --------------------------------------------------------------------- To unsubscribe, e-mail: jcs-dev-unsubscr...@jakarta.apache.org For additional commands, e-mail: jcs-dev-h...@jakarta.apache.org