You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jcs-users@jakarta.apache.org by gopalnb <go...@mykbl.com> on 2009/02/10 14:37:11 UTC

Disable JCS Cache by commenting region in cache.ccf

I need test the effectiveness of JCS caching with some of the java objects
that are otherwise always fetched from the DB in my Java application (e.g.
StateVO {CD, Name}). 


How should I configure the "# DEFAULT CACHE REGION" section of my cache.ccf
so that if a region is not explicitly defined in the cache.ccf, no caching
for that object would occur? I believe there should be some option by which:
if I comment out a particular pre-defined cache region in the cache.ccf, no
caching would occur for that object, without any change in the java code. 



I tried the following: 




JCS cache = null;
String cacheRegionName = "state";
cache = JCS.getInstance(cacheRegionName);

String getState(stateCode) {
StateVO state = (StateVO) getCache().get(stateCode);
  if (state == null) {
    state = dao.getState(stateCode);
    cache.put(stateCode, state);
  }
}



The StateVO objects are being cached and retrieved from the cache
irrespective of whether the "state" region is pre-defined in the cache.ccf.


What needs to be done so that the above objects would not be cached if I
comment out the state region?

I saw someone mention a "nocache" or "NOPCache" option - but could not find
the source or documentation supporting that. Any pointers?
-- 
View this message in context: http://www.nabble.com/Disable-JCS-Cache-by-commenting-region-in-cache.ccf-tp21933762p21933762.html
Sent from the JCS - Users mailing list archive at Nabble.com.

Re: Disable JCS Cache by commenting region in cache.ccf

Posted by gopalnb <go...@mykbl.com>.
Oh! Thanks Niall. I got confused by this - 
http://mail-archives.apache.org/mod_mbox/jakarta-jcs-users/200701.mbox/%3CA955EA1F8FE31749AEC8C998082F6C7C010CDA13@hai01.hippo.local%3E
NOPCache  mentioned on another list.

With this information, I was able to get caching turned off by default by
using the following:

# DEFAULT CACHE REGION
jcs.default=
jcs.default.cacheattributes.MaxObjects=0




Niall Gallagher wrote:
> 
> Hi gopalnb,

> 
> Set:

> 
> jcs.default.cacheattributes.MaxObjects=0

> 
> Kind regards,

> 
> Niall
> 

-- 
View this message in context: http://www.nabble.com/Disable-JCS-Cache-by-commenting-region-in-cache.ccf-tp21933762p21935852.html
Sent from the JCS - Users mailing list archive at Nabble.com.

Re: Disable JCS Cache by commenting region in cache.ccf

Posted by Niall Gallagher <ni...@switchfire.com>.
Hi gopalnb,

Set:

jcs.default.cacheattributes.MaxObjects=0

Kind regards,

Niall

-----Original Message-----
From: gopalnb <go...@mykbl.com>
Reply-to: "JCS Users List" <jc...@jakarta.apache.org>
To: jcs-users@jakarta.apache.org
Subject: Disable JCS Cache by commenting region in cache.ccf
Date: Tue, 10 Feb 2009 05:37:11 -0800 (PST)


I need test the effectiveness of JCS caching with some of the java objects
that are otherwise always fetched from the DB in my Java application (e.g.
StateVO {CD, Name}). 


How should I configure the "# DEFAULT CACHE REGION" section of my cache.ccf
so that if a region is not explicitly defined in the cache.ccf, no caching
for that object would occur? I believe there should be some option by which:
if I comment out a particular pre-defined cache region in the cache.ccf, no
caching would occur for that object, without any change in the java code. 



I tried the following: 




JCS cache = null;
String cacheRegionName = "state";
cache = JCS.getInstance(cacheRegionName);

String getState(stateCode) {
StateVO state = (StateVO) getCache().get(stateCode);
  if (state == null) {
    state = dao.getState(stateCode);
    cache.put(stateCode, state);
  }
}



The StateVO objects are being cached and retrieved from the cache
irrespective of whether the "state" region is pre-defined in the cache.ccf.


What needs to be done so that the above objects would not be cached if I
comment out the state region?

I saw someone mention a "nocache" or "NOPCache" option - but could not find
the source or documentation supporting that. Any pointers?