I seem to be losing about 90 % of my keys: 1. insert 500,000 elements in the cache via a loop 2. loop through and check whether all elements are accesable
The results and code snippets follow: STATS: The stats I get (verified both via a counter I implement) and via the stats() method are Thanks in advance Vin B from my code debugs: found 45963 in 490001 tries end get, ... found 55962 in 500001 tries from the stats: Region Name = testCache1 HitCountRam = 0 HitCountAux = 55962 ---------------------------LRU Memory Cache List Size = 9998 Map Size = 9998 Put Count = 555962 ==================================> ???? Hit Count = 0 Miss Count = 500000 =================================> why am I missing hits here ---------------------------Indexed Disk Cache Is Alive = true Key Map Size = 55962 ================================> ???? Data File Length = 38544627 Hit Count = 55962 Bytes Free = 0 Optimize Operation Count = 0 Times Optimized = 0 Recycle Count = 0 Recycle Bin Size = 0 Startup Size = 46431 Purgatory Hits = 0 Purgatory Size = 0 Working = true Alive = true Empty = true Size = 0 Jul 18, 2008 12:28:00 PM org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCache$ShutdownHook run WARNING: Region [testCache1] Disk cache not shutdown properly, shutting down now. CODE # DEFAULT CACHE REGION #jcs.default=DC,LTCP jcs.default=DC jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes jcs.default.cacheattributes.MaxObjects=10000 jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache # PRE-DEFINED CACHE REGIONS #jcs.region.testCache1=DC,LTCP jcs.region.testCache1=DC jcs.region.testCache1.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes jcs.region.testCache1.cacheattributes.MaxObjects=10000 jcs.region.testCache1.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache jcs.region.testCache1.cacheattributes.UseMemoryShrinker=true jcs.region.testCache1.cacheattributes.MaxMemoryIdleTimeSeconds=3600 jcs.region.testCache1.cacheattributes.ShrinkerIntervalSeconds=600 jcs.region.testCache1.cacheattributes.MaxSpoolPerRun=500 jcs.region.testCache1.elementattributes=org.apache.jcs.engine.ElementAttributes jcs.region.testCache1.elementattributes.IsEternal=true # AVAILABLE AUXILIARY CACHES jcs.auxiliary.DC=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheFactory jcs.auxiliary.DC.attributes=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes jcs.auxiliary.DC.attributes.DiskPath=c:/tmp jcs.auxiliary.DC.attributes.maxKeySize=1000000 /////////////////////////////////////////// package com.interlegis.ehcachevsjcs; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.jcs.JCS; import org.apache.jcs.access.exception.CacheException; import org.apache.jcs.engine.CompositeCacheAttributes; import org.apache.jcs.engine.behavior.ICompositeCacheAttributes; import org.apache.jcs.utils.struct.LRUMap; public class JCSApp { private static int MAX_NUM = 500000; private Log log = null; private JCS jcs = null; public void init() throws CacheException { log = LogFactory.getLog(LRUMap.class); jcs = JCS.getInstance("testCache1"); } public void insert(int key) throws CacheException { jcs.put(Integer.toString(key), new MyObjectVO(Integer.toString(key), "some string" + Integer.toString(key))); } public void insertMany(int maxNum) throws CacheException { for (int i = 0; i < maxNum; i++) { insert(i); if ((i % 10000) == 0) { System.out.println("inserted " + i + " records"); } } } public Object get(int key) { return jcs.get(Integer.toString(key)); } public void getMany(int maxNum) { int count = 0; int i = 0; for (i = 0; i < maxNum; i++) { if (get(i) != null) { count++; } if ((i % 10000) == 0) { System.out.println("found " + count + " in " + (i + 1) + " tries"); } } System.out.println("end get, ... found " + count + " in " + (i + 1) + " tries"); } public void junk() { } public void printStats() { ; System.out.println(jcs.getStats()); } public static void main(String[] args) { JCSApp jc = new JCSApp(); try { jc.init(); jc.insertMany(MAX_NUM); System.out.println("insert complete"); jc.getMany(MAX_NUM); jc.printStats(); } catch (CacheException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }