Here's the configuration (below code) I'm using. notice IsEternal and MaxLifeSeconds.
We have variable cache times for component cache so we set these programmatically. public void put(Key pKey, Object pValue, long pTTL) { try { mLock.writeLock().acquire(); if (pTTL == 0) { mLogger.warn("putting uncached object in cache " + pKey); return; } IElementAttributes attribs = mCache.getDefaultElementAttributes(); if( pTTL != -1 ) { attribs.setMaxLifeSeconds(pTTL); attribs.setIsEternal(false); } mCache.put(pKey.toString(), pValue, attribs); } catch(Exception e) { throw new CacheException("could not add to JCS region", e); } finally { mLock.writeLock().release(); } } ################################################################## # JCS homepage: http://jakarta.apache.org/jcs/ ################################################################## ################################################################## # mem cache settings ################################################################## jcs.default=DC jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttribut es jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory .lru.LRUMemoryCache jcs.default.cacheattributes.UseMemoryShrinker=true jcs.default.cacheattributes.ShrinkerIntervalSeconds=300 jcs.default.cacheattributes.MaxSpoolPerRun=64 ################################################################## # element attributes ################################################################## jcs.default.elementattributes=org.apache.jcs.engine.ElementAttributes jcs.default.elementattributes.MaxLifeSeconds=-1 jcs.default.elementattributes.IdleTime=-1 jcs.default.elementattributes.IsEternal=true jcs.default.elementattributes.IsSpool=true jcs.default.elementattributes.IsRemote=false jcs.default.elementattributes.IsLateral=false ################################################################## # default disk cache settings ################################################################## jcs.auxiliary.DC=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheF actory jcs.auxiliary.DC.attributes=org.apache.jcs.auxiliary.disk.indexed.Indexe dDiskCacheAttributes jcs.auxiliary.DC.attributes.MaxPurgatorySize=64 jcs.auxiliary.DC.attributes.MaxKeySize=1024 jcs.auxiliary.DC.attributes.OptimizeAtRemoveCount=256 jcs.auxiliary.DC.attributes.OptimizeOnShutdown=true jcs.auxiliary.DC.attributes.MaxRecycleBinSize=64 jcs.auxiliary.DC.attributes.EventQueueType=POOLED jcs.auxiliary.DC.attributes.EventQueuePoolName=disk_cache_event_queue ################################################################## # Disk Cache pool ################################################################## thread_pool.disk_cache_event_queue.boundarySize=50 thread_pool.disk_cache_event_queue.useBoundary=true thread_pool.disk_cache_event_queue.maximumPoolSize=30 thread_pool.disk_cache_event_queue.minimumPoolSize=4 thread_pool.disk_cache_event_queue.keepAliveTime=3500 thread_pool.disk_cache_event_queue.startUpSize=4 thread_pool.disk_cache_event_queue.whenBlockedPolicy=RUN ################################################################## # Component cache pool disk cache attributes # See runtime.cache.ComponentCachePool in cache-resource-config.xml for configuring the pool size ################################################################## # Following definitions are to be used by all component caches in this pool # # Number of object PER cache, total number of memory objects is (MaxObjects * cacheCount) in spring config jcs.region.component=DC jcs.region.component.cacheattributes.MaxObjects=40 ################################################################## ################################################################## # Following definitions are to be used by all page caches in this pool # # See runtime.cache.PageCachePool in cache-resource-config.xml for configuring the pool size ################################################################### # Number of object PER cache, total number of memory objects is (MaxObjects * cacheCount) in spring config jcs.region.page=DC jcs.region.page.cacheattributes.MaxObjects=128 ################################################################### ################################################################### # Stylesheet settings ################################################################### #disable disk caching if WAS doesn't provide serialized dom #jcs.region.stylesheet= jcs.region.component=DC jcs.region.stylesheet.cacheattributes.MaxObjects=128 ################################################################### ################################################################### # Rules settings ################################################################### jcs.region.component=DC jcs.region.rulesenginevalues.cacheattributes.MaxObjects=128 ################################################################### -----Original Message----- From: Bhandari, Shweta [mailto:shweta.bhand...@morganstanleysmithbarney.com] Sent: Tuesday, March 22, 2011 10:33 AM To: JCS Users List; Tim Cronin Subject: RE: JCS CONFIG Help Hello Tim, Thanks for your replu It works fine with the same code if I increase this particular parameter from jcs.default.cacheattributes.MaxObjects=50 to jcs.default.cacheattributes.MaxObjects=500000 and reduce the jcs.auxiliary.DC.attributes.MaxKeySize=200000 To jcs.auxiliary.DC.attributes.MaxKeySize=20 All I am trying to do is use disk based cache for majority of my objects. Let me know if you need anything else. Contents of ccf are provided below. jcs.default=DC jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttribut es jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory .lru.LRUMemoryCache jcs.default.cacheattributes.MaxObjects=50 jcs.default.cacheattributes.UseMemoryShrinker=false jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=10800 jcs.default.cacheattributes.ShrinkerIntervalSeconds=3600 jcs.default.elementattributes=org.apache.jcs.engine.ElementAttributes jcs.default.elementattributes.IsEternal=false jcs.default.elementattributes.MaxLifeSeconds=36000 jcs.default.elementattributes.IsSpool=true jcs.default.elementattributes.IsRemote=false jcs.default.elementattributes.IsLateral=false ############################################################## ##### AUXILIARY CACHES # Indexed Disk Cache jcs.auxiliary.DC=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheF actory jcs.auxiliary.DC.attributes=org.apache.jcs.auxiliary.disk.indexed.Indexe dDiskCacheAttributes jcs.auxiliary.DC.attributes.DiskPath=/tmp/rms jcs.auxiliary.DC.attributes.MaxKeySize=200000 jcs.auxiliary.DC.attributes.MaxPurgatorySize=200000 jcs.auxiliary.DC.attributes.ClearDiskOnStartup=true cs.auxiliary.DC.attributes.MaxRecycleBinSize=10000 Thanks for your help, Shweta -----Original Message----- From: Tim Cronin [mailto:tim.cro...@autonomy.com] Sent: Tuesday, March 22, 2011 11:30 AM To: JCS Users List Subject: RE: JCS CONFIG Help Do you have sample code of how you suing the cache? -----Original Message----- From: Bhandari, Shweta [mailto:shweta.bhand...@morganstanleysmithbarney.com] Sent: Tuesday, March 22, 2011 8:46 AM To: jcs-users@jakarta.apache.org Subject: JCS CONFIG Help Hello Everyone, I am new to JCS and I am trying to use JCS in my webapp. All I want to use is diskbasedcache to reduce the memory usage on tomcat server. Looks like my parameters in ccf are wrong . I perpetually get null pointer exception for the object which I Put in the cache. It seems like my object is lost Please advise. Here are the contents of my ccf file for your perusal Thanks, Shweta jcs.default=DC jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttribut es jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory .lru.LRUMemoryCache jcs.default.cacheattributes.MaxObjects=50 jcs.default.cacheattributes.UseMemoryShrinker=false jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=10800 jcs.default.cacheattributes.ShrinkerIntervalSeconds=3600 jcs.default.elementattributes=org.apache.jcs.engine.ElementAttributes jcs.default.elementattributes.IsEternal=false jcs.default.elementattributes.MaxLifeSeconds=36000 jcs.default.elementattributes.IsSpool=true jcs.default.elementattributes.IsRemote=false jcs.default.elementattributes.IsLateral=false ############################################################## ##### AUXILIARY CACHES # Indexed Disk Cache jcs.auxiliary.DC=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheF actory jcs.auxiliary.DC.attributes=org.apache.jcs.auxiliary.disk.indexed.Indexe dDiskCacheAttributes jcs.auxiliary.DC.attributes.DiskPath=/tmp/rms jcs.auxiliary.DC.attributes.MaxKeySize=200000 jcs.auxiliary.DC.attributes.MaxPurgatorySize=200000 jcs.auxiliary.DC.attributes.ClearDiskOnStartup=true cs.auxiliary.DC.attributes.MaxRecycleBinSize=10000 ________________________________ Important Notice to Recipients: The sender of this e-mail is an employee of Morgan Stanley Smith Barney LLC. If you have received this communication in error, please destroy all electronic and paper copies and notify the sender immediately. Erroneous transmission is not intended to waive confidentiality or privilege. Morgan Stanley Smith Barney reserves the right, to the extent permitted under applicable law, to monitor electronic communications. This message is subject to terms available at the following link: http://www.morganstanley.com/disclaimers/mssbemail.html. If you cannot access this link, please notify us by reply message and we will send the contents to you. By messaging with Morgan Stanley Smith Barney you consent to the foregoing. ------------------------------------------------------------------------ -- Important Notice to Recipients: The sender of this e-mail is an employee of Morgan Stanley Smith Barney LLC. If you have received this communication in error, please destroy all electronic and paper copies and notify the sender immediately. Erroneous transmission is not intended to waive confidentiality or privilege. Morgan Stanley Smith Barney reserves the right, to the extent permitted under applicable law, to monitor electronic communications. This message is subject to terms available at the following link: http://www.morganstanley.com/disclaimers/mssbemail.html. If you cannot access this link, please notify us by reply message and we will send the contents to you. By messaging with Morgan Stanley Smith Barney you consent to the foregoing. --------------------------------------------------------------------- To unsubscribe, e-mail: jcs-users-unsubscr...@jakarta.apache.org For additional commands, e-mail: jcs-users-h...@jakarta.apache.org ------------------------------------------------------------------------ -- Important Notice to Recipients: The sender of this e-mail is an employee of Morgan Stanley Smith Barney LLC. If you have received this communication in error, please destroy all electronic and paper copies and notify the sender immediately. Erroneous transmission is not intended to waive confidentiality or privilege. Morgan Stanley Smith Barney reserves the right, to the extent permitted under applicable law, to monitor electronic communications. This message is subject to terms available at the following link: http://www.morganstanley.com/disclaimers/mssbemail.html. If you cannot access this link, please notify us by reply message and we will send the contents to you. By messaging with Morgan Stanley Smith Barney you consent to the foregoing. --------------------------------------------------------------------- To unsubscribe, e-mail: jcs-users-unsubscr...@jakarta.apache.org For additional commands, e-mail: jcs-users-h...@jakarta.apache.org