-
1. Re: How to configure region based caching & use multiple cac
brian.stansberry Apr 13, 2009 4:16 PM (in response to aman21cent)You can't configure different cache loaders for different regions.
Do you want to configure the cache loader for passivation? If so, you can just configure the FileCacheLoader for everything and only evict from certain regions. -
2. Re: How to configure region based caching & use multiple cac
aman21cent Apr 13, 2009 4:51 PM (in response to aman21cent)My actual goal is to use 2 different cache loaders for 2 different regions like below -
Region /user/data/X - use JDBCCacheLoader
Region /user/data/Y - use - FileCacheLoader
I will use passivation & eviction on both regions but how can I use different loaders on individual regions? -
3. Re: How to configure region based caching & use multiple cac
aman21cent Apr 13, 2009 4:56 PM (in response to aman21cent)I can run 2 sets of JBoss cache instance...& providing two configuration files....but I am trying to avoid it.
Can I configure region based cache loaders & run single instance of JBOSS cache? -
4. Re: How to configure region based caching & use multiple cac
brian.stansberry Apr 13, 2009 4:59 PM (in response to aman21cent)I don't think you can.
You can try posting on the JBoss Cache user forum and see if someone has a clever suggestion. Only thing that comes to mind for me is subclassing JDBCCacheLoader and FileCacheLoader such that they take a configuration attribute that defines the region they apply to. Then use JBC's chaining cache loader functionality[1] to deploy multiple cache loaders, each configured for a different region. But I don't know whether that would really work in practice or whether there would be insurmountable gotchas.
[1] http://www.jboss.org/file-access/default/members/jbosscache/freezone/docs/3.1.0.CR1/userguide_en/html/cache_loaders.html#d0e3246 -
5. Re: How to configure region based caching & use multiple cac
aman21cent Apr 14, 2009 8:28 AM (in response to aman21cent)Thanks for your feedback.
Another question - is it possible to do replication at region level?
Region X - Turn ON replication
Region Y - Turn OFF replication, which means keep the cache on local server only. -
6. Re: How to configure region based caching & use multiple cac
brian.stansberry Apr 14, 2009 11:01 AM (in response to aman21cent)Not via configuration. The application could use the JBC Option API and setCacheModeLocal(true) before any writes to the region.
-
7. Re: How to configure region based caching & use multiple cac
aman21cent Apr 14, 2009 2:57 PM (in response to aman21cent)Yes, but this won't work in case of multi threaded environment.
Thread # 1 - Writes into Region X
Thread # 2 - Writes into Region Y at exact same time as Thread # 1
If cache mode set to local then both Region X & Y will not be replicated. Is this true? -
8. Re: How to configure region based caching & use multiple cac
brian.stansberry Apr 14, 2009 3:24 PM (in response to aman21cent)That won't be a problem; the option is scoped to the calling thread. It's stored in a ThreadLocal and is cleared when the next call to the cache after it's set returns.
Admittedly, it's a clunky API. In JBC 1.x the Option was passed as a method param in an overloaded method, which was more intuitive but added tons of overloaded methods. -
9. Re: How to configure region based caching & use multiple cac
aman21cent Apr 15, 2009 7:39 AM (in response to aman21cent)Could you please verify below steps on how this will be working -
Region X - needs to be replicated
Region Y - doesn't need to be replicated
Thread # 1 - Writes/puts into Region X in below steps
a. Writes/puts into Region X
Thread # 2 - Writes into Region Y at exact same time as Thread # 1 in below steps
a. Before writing/putting into the cache, call setCacheModeLocal(true)
b. Writes/puts into Region Y
Thread # 3 - Writes into Region X at exact same time as Thread # 1 in below steps
a. Writes/puts into Region X
As per your comments Thread # 2 step a) setCacheModeLocal variable is stored locally to it's own thread.
Let's go step by step -
1. Thread # 1 step a) is about to write into the region X & before it completes it's writing/putting step....
2. Thread # 2 step a) sets it to local cache mode.
3. Thread # 1 step a) is now actually writing into the cache - assuming default value of local cache mode variable is false this will be replicated - right?
4. Thread # 2 step b) writes into region Y - it stores locally.
5. Thread # 3 step a) - same as Thread # 1 - correct?
So I just need to call setCacheModeLocal(true) only before writing/putting into Region Y. Default value of this variable in local threads is false - right? -
10. Re: How to configure region based caching & use multiple cac
brian.stansberry Apr 15, 2009 10:51 AM (in response to aman21cent)Correct.
-
11. Re: How to configure region based caching & use multiple cac
aman21cent Apr 16, 2009 10:30 AM (in response to aman21cent)Thank you.