-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: JCS cache properties
PostPosted: Wed Nov 12, 2003 12:42 pm 
Beginner
Beginner

Joined: Wed Aug 27, 2003 8:55 am
Posts: 28
Location: Dallas, TX
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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 14, 2003 3:00 pm 
Newbie

Joined: Wed Aug 27, 2003 2:53 pm
Posts: 14
Location: New Jersey
I'm certainly no expert on JCS, but I am successfully using it (sort of) with Hibernate 2.0.

The "DC" is supposed to reference another cache configuration (which is typically a Disk Cache -- hence the DC). The full cache configuration at the beginning of your post includes a commented-out definition of a disk cache (jcs.auxiliary.DC). You don't have one defined, so that's why you see the "ERROR" when you start-up.

Hibernate creates a different JCS region for each <jcs-cache> tag you have in your mapping file. The cache names are the fully qualified name of the class for class-level caching. For caching of properties (one-to-many or many-to-many collections), the cache name is the fully qualified name of the class containing the property with ".<property_name>" appended. So you could configure each JCS cache that hibernate will use individually.

The "jcs.default" cache configuration is used as the configuration for any region that is not explicitly provide a cache configuration. The cache configuration at the beginning of your posting defines cache configurations for three regions -- Country, Region, CreditCard -- plus the default "jcs.default" to be used for any other regions.

MaxObjects indicates the maximum number of objects that can exist within a region configured by those properties. Your understanding of MaxLifeSeconds and IdleTime is correct. I'm not sure what IsEternal, isSpool, IsRemote and IsLateral do, but I don't have any them defined in my cache configuration and things work fine. I'd assume that IsRemote/IsLateral have to do with whether you're using a remote cache or a lateral cache (which in your example, you aren't because you are using a memory cache).

Just so you know, JCS's LRUMemoryCache causes memory leaks. There's a post on this forum that discusses the problems in detail. . . search for Topic "JCS IndexedDiskCache deadlock/LRUMemoryCache memory leak" from October 2003. Since we actually want our cached objects to have an infinite life, we wrote our own Cache class that extends JCS's AbstractMemoryCache class and is just a wrapper around HashMap.

There also seems to be a problem with JCS starting a Thread associated with each region that is created. The Thread seems to just block and do nothing, but it's still weird.

Hope this helps.

Sarah


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.