I am trying to implement caching with Hibernate using JCS. To get started, I basically ripped off the cache.ccf file from the Hibernate example here:
http://www.hibernate.org/61.html
Code:
# DEFAULT CACHE REGION (memory cache)
jcs.default=DC
jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.default.cacheattributes.MaxObjects=2000
jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
jcs.default.elementattributes=org.apache.jcs.engine.ElementAttributes
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLifeSeconds=24000
jcs.default.elementattributes.IdleTime=180000
jcs.default.elementattributes.IsSpool=false
jcs.default.elementattributes.IsRemote=false
jcs.default.elementattributes.IsLateral=false
#Country Cache
jcs.region.com.gregluck.domain.Country=DC
jcs.region.com.gregluck.domain.Country.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.region.com.gregluck.domain.Country.cacheattributes.MaxObjects=1000
jcs.region.com.gregluck.domain.Country.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
jcs.region.com.gregluck.domain.Country.cacheattributes.UseMemoryShrinker=true
jcs.region.com.gregluck.domain.Country.cacheattributes.MaxMemoryIdleTimeSeconds=3600
jcs.region.com.gregluck.domain.Country.cacheattributes.ShrinkerIntervalSeconds=60
jcs.region.com.gregluck.domain.Country.elementattributes=org.apache.jcs.engine.ElementAttributes
jcs.region.com.gregluck.domain.Country.elementattributes.IsEternal=false
jcs.region.com.gregluck.domain.Country.elementattributes.MaxLifeSeconds=240
jcs.region.com.gregluck.domain.Country.elementattributes.IdleTime=180
jcs.region.com.gregluck.domain.Country.elementattributes.IsSpool=false
jcs.region.com.gregluck.domain.Country.elementattributes.IsRemote=false
jcs.region.com.gregluck.domain.Country.elementattributes.IsLateral=false
#Region Cache
jcs.region.com.gregluck.domain.Region=DC
jcs.region.com.gregluck.domain.Region.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.region.com.gregluck.domain.Region.cacheattributes.MaxObjects=1000
jcs.region.com.gregluck.domain.Region.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
jcs.region.com.gregluck.domain.Region.cacheattributes.UseMemoryShrinker=true
jcs.region.com.gregluck.domain.Region.cacheattributes.MaxMemoryIdleTimeSeconds=3600
jcs.region.com.gregluck.domain.Region.cacheattributes.ShrinkerIntervalSeconds=60
jcs.region.com.gregluck.domain.Region.elementattributes=org.apache.jcs.engine.ElementAttributes
jcs.region.com.gregluck.domain.Region.elementattributes.IsEternal=false
jcs.region.com.gregluck.domain.Region.elementattributes.MaxLifeSeconds=240
jcs.region.com.gregluck.domain.Region.elementattributes.IdleTime=180
jcs.region.com.gregluck.domain.Region.elementattributes.IsSpool=false
jcs.region.com.gregluck.domain.Region.elementattributes.IsRemote=false
jcs.region.com.gregluck.domain.Region.elementattributes.IsLateral=false
#CreditCard Cache
jcs.region.com.gregluck.domain.CreditCard=DC
jcs.region.com.gregluck.domain.CreditCard.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.region.com.gregluck.domain.CreditCard.cacheattributes.MaxObjects=1000
jcs.region.com.gregluck.domain.CreditCard.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
jcs.region.com.gregluck.domain.CreditCard.cacheattributes.UseMemoryShrinker=true
jcs.region.com.gregluck.domain.CreditCard.cacheattributes.MaxMemoryIdleTimeSeconds=3600
jcs.region.com.gregluck.domain.CreditCard.cacheattributes.ShrinkerIntervalSeconds=60
jcs.region.com.gregluck.domain.CreditCard.elementattributes=org.apache.jcs.engine.ElementAttributes
jcs.region.com.gregluck.domain.CreditCard.elementattributes.IsEternal=false
jcs.region.com.gregluck.domain.CreditCard.elementattributes.MaxLifeSeconds=240
jcs.region.com.gregluck.domain.CreditCard.elementattributes.IdleTime=180
jcs.region.com.gregluck.domain.CreditCard.elementattributes.IsSpool=false
jcs.region.com.gregluck.domain.CreditCard.elementattributes.IsRemote=false
jcs.region.com.gregluck.domain.CreditCard.elementattributes.IsLateral=false
# System CACHE REGION (unused)
#jcs.system.groupIdCache=DC
#jcs.system.groupIdCache.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
#jcs.system.groupIdCache.cacheattributes.MaxObjects=10000
#jcs.system.groupIdCache.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
#Auxiliary CACHE (disk cache) (unused)
#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=cache
#Lateral TCP Cache (unused)
#jcs.auxiliary.LTCP=org.apache.jcs.auxiliary.lateral.LateralCacheFactory
#jcs.auxiliary.LTCP.attributes=org.apache.jcs.auxiliary.lateral.LateralCacheAttributes
#jcs.auxiliary.LTCP.attributes.TransmissionTypeName=TCP
#jcs.auxiliary.LTCP.attributes.TcpServers=localhost:1111
#jcs.auxiliary.LTCP.attributes.TcpListenerPort=1110
#jcs.auxiliary.LTCP.attributes.PutOnlyMode=false
Since I know very little about JCS, I shortened this file for my purposes:
Code:
# DEFAULT CACHE REGION (memory cache)
jcs.default=DC
jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.default.cacheattributes.MaxObjects=2000
jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
jcs.default.elementattributes=org.apache.jcs.engine.ElementAttributes
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLifeSeconds=24000
jcs.default.elementattributes.IdleTime=180000
jcs.default.elementattributes.IsSpool=false
jcs.default.elementattributes.IsRemote=false
jcs.default.elementattributes.IsLateral=false
My problem is I really have no idea what this does. I understand that you can have different "regions" for different objects. How this is done is unclear. I assume my above configuration means that the total number of objects I can cache is 2000, any object will get booted from cache after 24000 seconds, and any object will get booted if not hit after 18000 seconds. The cache uses a LRU algorithm. The rest is a mystery to me.
I found the JCS web site's docs woefully lacking (like any Turbine-related project). I tried searching their user mailing list, but that is currently broken. So, here I am. Can anybody explain how the JCS configuration file works. What are the critical propeties. How do I configure a default cache and cache regions for particular objects. What the hell is "DC"? I think I know, but JCS logs certain things as ERRORs when they don't appear to be:
Code:
[ WARN] 10:37:54 OptionConverter.instantiateByKey - Could not find value for key jcs.auxiliary.DC
[ERROR] 10:37:54 CompositeCacheConfigurator.parseAuxiliary - Could not instantiate auxFactory named "DC".
Huh? Quite confusing.
Thanks for the help.
Ryan