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 KWeisser <ke...@us.ibm.com> on 2008/02/18 17:34:19 UTC

Objects disappearing from cache

I'm currently using JCS to cache the search results returned from a query,
and then using the cache to help me implement pagination.  I'm running
Rational Software Architect 7.0.0.4, and am experiencing some odd behavior.

Initially, I am able to set the result set (an ArrayList of 200 Object) onto
the cache.  I then access the cache to fetch the first 10 results from the
ArrayList.  The cache is also accessed to determine the total number of
records that I have.  I'm typically able to access this ArrayList off the
cache 4 or 5 times, and after that the get method returns null for my
ArrayList.  Any idea why this object is dissappearing from the cache after
several times of successfully accessing the ArrayList?  Any help is greatly
appreciated.

Here is my cache.ccf file:
# DEFAULT CACHE REGION

jcs.default=DC,LTCP
jcs.default.cacheattributes=
    org.apache.jcs.engine.CompositeCacheAttributes
jcs.default.cacheattributes.MaxObjects=1000
jcs.default.cacheattributes.MemoryCacheName=
    org.apache.jcs.engine.memory.lru.LRUMemoryCache

# PRE-DEFINED CACHE REGIONS

jcs.region.testCache1=DC,LTCP
jcs.region.testCache1.cacheattributes=
    org.apache.jcs.engine.CompositeCacheAttributes
jcs.region.testCache1.cacheattributes.MaxObjects=1000
jcs.region.testCache1.cacheattributes.MemoryCacheName=
    org.apache.jcs.engine.memory.lru.LRUMemoryCache
jcs.region.testCache1.cacheattributes.UseMemoryShrinker=true
jcs.region.testCache1.cacheattributes.MaxMemoryIdleTimeSeconds=3600
jcs.region.testCache1.cacheattributes.ShrinkerIntervalSeconds=60
jcs.region.testCache1.cacheattributes.MaxSpoolPerRun=500
jcs.region.testCache1.elementattributes=org.apache.jcs.engine.ElementAttributes
jcs.region.testCache1.elementattributes.IsEternal=false


# AVAILABLE AUXILIARY CACHES
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=g:/dev/jcs/raf
jcs.auxiliary.DC.attributes.maxKeySize=100000

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

Here is my code accessing the cache:
/**
 * This is a sample LazyLoading DataScroller that
 * uses the JSF LazyLoading DataScroller library
 * @author hazems
 */
public class MyLazyLoadingDataScroller extends
AbstractLazyLoadingDataScroller {

	public MyLazyLoadingDataScroller() {
		//Pass the id of the dataTable to the AbstractLazyLoadingDataScroller base
		super("tableEx1");
	}

	/**
	 * Override for getting the data from the Database
	 * Use the getOffset() and the getPageSize() to know
	 * the From and To records to be gotten from the Database  
	 */
	public List getPageData() {
		int pageSize = getPageSize();
		int offset = getOffset();
		List pageData = new ArrayList();		
		ArrayList lst = new ArrayList();

		try {
			JCS cache = JCS.getInstance("default");
			lst = (ArrayList)cache.get("caseSrchResults");
			
			if (lst != null){
				for (int i = offset; (i < pageSize + offset) && (i < lst.size()); ++i) {
					pageData.add(lst.get(i));
				}
			}
	    } catch ( CacheException e ) {
	    	e.printStackTrace();
	    }
	
		return pageData;
	}

	public int getStart(){
		return getOffset();
	}
	
	public int getEnd(){
		return getPageSize() + getOffset();
	}
	
	/**
	 * Override this method to return the total number of records
	 */
	public int getTotalNumberOfRows() {
		ArrayList lst = new ArrayList();

		// in your constructor you might do this
		try {
			JCS cache = JCS.getInstance("default");
			lst = (ArrayList)cache.get("caseSrchResults");
	    } catch ( CacheException e ) {
	    	e.printStackTrace();
	    } catch ( Exception e){
	    	e.printStackTrace();
	    }
	    if (lst == null) return 0;
	    else return lst.size();
	}
}

-- 
View this message in context: http://www.nabble.com/Objects-disappearing-from-cache-tp15547022p15547022.html
Sent from the JCS - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: jcs-users-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jcs-users-help@jakarta.apache.org


Re: Objects disappearing from cache

Posted by hanasaki jiji <ha...@gmail.com>.
Just remember that nothing will auto-age out of the cache with these settings.

On Feb 19, 2008 3:08 PM, Al Forbes <fo...@googlemail.com> wrote:
> Hi,
>
> I did not look at the details of you problem. JCS does work, so try these:
>
> jcs.default.elementattributes.IdleTime=-1
>
> jcs.region.testCache1.elementattributes.IsEternal=true
>
>
>
> On 18/02/2008, KWeisser <ke...@us.ibm.com> wrote:
> >
> > I'm currently using JCS to cache the search results returned from a query,
> > and then using the cache to help me implement pagination.  I'm running
> > Rational Software Architect 7.0.0.4, and am experiencing some odd behavior.
> >
> > Initially, I am able to set the result set (an ArrayList of 200 Object) onto
> > the cache.  I then access the cache to fetch the first 10 results from the
> > ArrayList.  The cache is also accessed to determine the total number of
> > records that I have.  I'm typically able to access this ArrayList off the
> > cache 4 or 5 times, and after that the get method returns null for my
> > ArrayList.  Any idea why this object is dissappearing from the cache after
> > several times of successfully accessing the ArrayList?  Any help is greatly
> > appreciated.
> >
> > Here is my cache.ccf file:
> > # DEFAULT CACHE REGION
> >
> > jcs.default=DC,LTCP
> > jcs.default.cacheattributes=
> >     org.apache.jcs.engine.CompositeCacheAttributes
> > jcs.default.cacheattributes.MaxObjects=1000
> > jcs.default.cacheattributes.MemoryCacheName=
> >     org.apache.jcs.engine.memory.lru.LRUMemoryCache
> >
> > # PRE-DEFINED CACHE REGIONS
> >
> > jcs.region.testCache1=DC,LTCP
> > jcs.region.testCache1.cacheattributes=
> >     org.apache.jcs.engine.CompositeCacheAttributes
> > jcs.region.testCache1.cacheattributes.MaxObjects=1000
> > jcs.region.testCache1.cacheattributes.MemoryCacheName=
> >     org.apache.jcs.engine.memory.lru.LRUMemoryCache
> > jcs.region.testCache1.cacheattributes.UseMemoryShrinker=true
> > jcs.region.testCache1.cacheattributes.MaxMemoryIdleTimeSeconds=3600
> > jcs.region.testCache1.cacheattributes.ShrinkerIntervalSeconds=60
> > jcs.region.testCache1.cacheattributes.MaxSpoolPerRun=500
> > jcs.region.testCache1.elementattributes=org.apache.jcs.engine.ElementAttributes
> > jcs.region.testCache1.elementattributes.IsEternal=false
> >
> >
> > # AVAILABLE AUXILIARY CACHES
> > 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=g:/dev/jcs/raf
> > jcs.auxiliary.DC.attributes.maxKeySize=100000
> >
> > 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
> >
> > Here is my code accessing the cache:
> > /**
> >  * This is a sample LazyLoading DataScroller that
> >  * uses the JSF LazyLoading DataScroller library
> >  * @author hazems
> >  */
> > public class MyLazyLoadingDataScroller extends
> > AbstractLazyLoadingDataScroller {
> >
> >         public MyLazyLoadingDataScroller() {
> >                 //Pass the id of the dataTable to the AbstractLazyLoadingDataScroller base
> >                 super("tableEx1");
> >         }
> >
> >         /**
> >          * Override for getting the data from the Database
> >          * Use the getOffset() and the getPageSize() to know
> >          * the From and To records to be gotten from the Database
> >          */
> >         public List getPageData() {
> >                 int pageSize = getPageSize();
> >                 int offset = getOffset();
> >                 List pageData = new ArrayList();
> >                 ArrayList lst = new ArrayList();
> >
> >                 try {
> >                         JCS cache = JCS.getInstance("default");
> >                         lst = (ArrayList)cache.get("caseSrchResults");
> >
> >                         if (lst != null){
> >                                 for (int i = offset; (i < pageSize + offset) && (i < lst.size()); ++i) {
> >                                         pageData.add(lst.get(i));
> >                                 }
> >                         }
> >             } catch ( CacheException e ) {
> >                 e.printStackTrace();
> >             }
> >
> >                 return pageData;
> >         }
> >
> >         public int getStart(){
> >                 return getOffset();
> >         }
> >
> >         public int getEnd(){
> >                 return getPageSize() + getOffset();
> >         }
> >
> >         /**
> >          * Override this method to return the total number of records
> >          */
> >         public int getTotalNumberOfRows() {
> >                 ArrayList lst = new ArrayList();
> >
> >                 // in your constructor you might do this
> >                 try {
> >                         JCS cache = JCS.getInstance("default");
> >                         lst = (ArrayList)cache.get("caseSrchResults");
> >             } catch ( CacheException e ) {
> >                 e.printStackTrace();
> >             } catch ( Exception e){
> >                 e.printStackTrace();
> >             }
> >             if (lst == null) return 0;
> >             else return lst.size();
> >         }
> > }
> >
> > --
> > View this message in context: http://www.nabble.com/Objects-disappearing-from-cache-tp15547022p15547022.html
> > Sent from the JCS - Users mailing list archive at Nabble.com.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: jcs-users-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: jcs-users-help@jakarta.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jcs-users-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jcs-users-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jcs-users-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jcs-users-help@jakarta.apache.org


Re: Objects disappearing from cache

Posted by Al Forbes <fo...@googlemail.com>.
Hi,

I did not look at the details of you problem. JCS does work, so try these:

jcs.default.elementattributes.IdleTime=-1

jcs.region.testCache1.elementattributes.IsEternal=true


On 18/02/2008, KWeisser <ke...@us.ibm.com> wrote:
>
> I'm currently using JCS to cache the search results returned from a query,
> and then using the cache to help me implement pagination.  I'm running
> Rational Software Architect 7.0.0.4, and am experiencing some odd behavior.
>
> Initially, I am able to set the result set (an ArrayList of 200 Object) onto
> the cache.  I then access the cache to fetch the first 10 results from the
> ArrayList.  The cache is also accessed to determine the total number of
> records that I have.  I'm typically able to access this ArrayList off the
> cache 4 or 5 times, and after that the get method returns null for my
> ArrayList.  Any idea why this object is dissappearing from the cache after
> several times of successfully accessing the ArrayList?  Any help is greatly
> appreciated.
>
> Here is my cache.ccf file:
> # DEFAULT CACHE REGION
>
> jcs.default=DC,LTCP
> jcs.default.cacheattributes=
>     org.apache.jcs.engine.CompositeCacheAttributes
> jcs.default.cacheattributes.MaxObjects=1000
> jcs.default.cacheattributes.MemoryCacheName=
>     org.apache.jcs.engine.memory.lru.LRUMemoryCache
>
> # PRE-DEFINED CACHE REGIONS
>
> jcs.region.testCache1=DC,LTCP
> jcs.region.testCache1.cacheattributes=
>     org.apache.jcs.engine.CompositeCacheAttributes
> jcs.region.testCache1.cacheattributes.MaxObjects=1000
> jcs.region.testCache1.cacheattributes.MemoryCacheName=
>     org.apache.jcs.engine.memory.lru.LRUMemoryCache
> jcs.region.testCache1.cacheattributes.UseMemoryShrinker=true
> jcs.region.testCache1.cacheattributes.MaxMemoryIdleTimeSeconds=3600
> jcs.region.testCache1.cacheattributes.ShrinkerIntervalSeconds=60
> jcs.region.testCache1.cacheattributes.MaxSpoolPerRun=500
> jcs.region.testCache1.elementattributes=org.apache.jcs.engine.ElementAttributes
> jcs.region.testCache1.elementattributes.IsEternal=false
>
>
> # AVAILABLE AUXILIARY CACHES
> 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=g:/dev/jcs/raf
> jcs.auxiliary.DC.attributes.maxKeySize=100000
>
> 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
>
> Here is my code accessing the cache:
> /**
>  * This is a sample LazyLoading DataScroller that
>  * uses the JSF LazyLoading DataScroller library
>  * @author hazems
>  */
> public class MyLazyLoadingDataScroller extends
> AbstractLazyLoadingDataScroller {
>
>         public MyLazyLoadingDataScroller() {
>                 //Pass the id of the dataTable to the AbstractLazyLoadingDataScroller base
>                 super("tableEx1");
>         }
>
>         /**
>          * Override for getting the data from the Database
>          * Use the getOffset() and the getPageSize() to know
>          * the From and To records to be gotten from the Database
>          */
>         public List getPageData() {
>                 int pageSize = getPageSize();
>                 int offset = getOffset();
>                 List pageData = new ArrayList();
>                 ArrayList lst = new ArrayList();
>
>                 try {
>                         JCS cache = JCS.getInstance("default");
>                         lst = (ArrayList)cache.get("caseSrchResults");
>
>                         if (lst != null){
>                                 for (int i = offset; (i < pageSize + offset) && (i < lst.size()); ++i) {
>                                         pageData.add(lst.get(i));
>                                 }
>                         }
>             } catch ( CacheException e ) {
>                 e.printStackTrace();
>             }
>
>                 return pageData;
>         }
>
>         public int getStart(){
>                 return getOffset();
>         }
>
>         public int getEnd(){
>                 return getPageSize() + getOffset();
>         }
>
>         /**
>          * Override this method to return the total number of records
>          */
>         public int getTotalNumberOfRows() {
>                 ArrayList lst = new ArrayList();
>
>                 // in your constructor you might do this
>                 try {
>                         JCS cache = JCS.getInstance("default");
>                         lst = (ArrayList)cache.get("caseSrchResults");
>             } catch ( CacheException e ) {
>                 e.printStackTrace();
>             } catch ( Exception e){
>                 e.printStackTrace();
>             }
>             if (lst == null) return 0;
>             else return lst.size();
>         }
> }
>
> --
> View this message in context: http://www.nabble.com/Objects-disappearing-from-cache-tp15547022p15547022.html
> Sent from the JCS - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jcs-users-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jcs-users-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jcs-users-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jcs-users-help@jakarta.apache.org


Re: Objects disappearing from cache

Posted by hanasaki jiji <ha...@gmail.com>.
I suspect it is no longer in the cache.  Use the provided tools to
peek into the region.  Perhaps it was pushed out for space reasons or
time out?

On Feb 18, 2008 10:34 AM, KWeisser <ke...@us.ibm.com> wrote:
>
> I'm currently using JCS to cache the search results returned from a query,
> and then using the cache to help me implement pagination.  I'm running
> Rational Software Architect 7.0.0.4, and am experiencing some odd behavior.
>
> Initially, I am able to set the result set (an ArrayList of 200 Object) onto
> the cache.  I then access the cache to fetch the first 10 results from the
> ArrayList.  The cache is also accessed to determine the total number of
> records that I have.  I'm typically able to access this ArrayList off the
> cache 4 or 5 times, and after that the get method returns null for my
> ArrayList.  Any idea why this object is dissappearing from the cache after
> several times of successfully accessing the ArrayList?  Any help is greatly
> appreciated.
>
> Here is my cache.ccf file:
> # DEFAULT CACHE REGION
>
> jcs.default=DC,LTCP
> jcs.default.cacheattributes=
>     org.apache.jcs.engine.CompositeCacheAttributes
> jcs.default.cacheattributes.MaxObjects=1000
> jcs.default.cacheattributes.MemoryCacheName=
>     org.apache.jcs.engine.memory.lru.LRUMemoryCache
>
> # PRE-DEFINED CACHE REGIONS
>
> jcs.region.testCache1=DC,LTCP
> jcs.region.testCache1.cacheattributes=
>     org.apache.jcs.engine.CompositeCacheAttributes
> jcs.region.testCache1.cacheattributes.MaxObjects=1000
> jcs.region.testCache1.cacheattributes.MemoryCacheName=
>     org.apache.jcs.engine.memory.lru.LRUMemoryCache
> jcs.region.testCache1.cacheattributes.UseMemoryShrinker=true
> jcs.region.testCache1.cacheattributes.MaxMemoryIdleTimeSeconds=3600
> jcs.region.testCache1.cacheattributes.ShrinkerIntervalSeconds=60
> jcs.region.testCache1.cacheattributes.MaxSpoolPerRun=500
> jcs.region.testCache1.elementattributes=org.apache.jcs.engine.ElementAttributes
> jcs.region.testCache1.elementattributes.IsEternal=false
>
>
> # AVAILABLE AUXILIARY CACHES
> 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=g:/dev/jcs/raf
> jcs.auxiliary.DC.attributes.maxKeySize=100000
>
> 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
>
> Here is my code accessing the cache:
> /**
>  * This is a sample LazyLoading DataScroller that
>  * uses the JSF LazyLoading DataScroller library
>  * @author hazems
>  */
> public class MyLazyLoadingDataScroller extends
> AbstractLazyLoadingDataScroller {
>
>         public MyLazyLoadingDataScroller() {
>                 //Pass the id of the dataTable to the AbstractLazyLoadingDataScroller base
>                 super("tableEx1");
>         }
>
>         /**
>          * Override for getting the data from the Database
>          * Use the getOffset() and the getPageSize() to know
>          * the From and To records to be gotten from the Database
>          */
>         public List getPageData() {
>                 int pageSize = getPageSize();
>                 int offset = getOffset();
>                 List pageData = new ArrayList();
>                 ArrayList lst = new ArrayList();
>
>                 try {
>                         JCS cache = JCS.getInstance("default");
>                         lst = (ArrayList)cache.get("caseSrchResults");
>
>                         if (lst != null){
>                                 for (int i = offset; (i < pageSize + offset) && (i < lst.size()); ++i) {
>                                         pageData.add(lst.get(i));
>                                 }
>                         }
>             } catch ( CacheException e ) {
>                 e.printStackTrace();
>             }
>
>                 return pageData;
>         }
>
>         public int getStart(){
>                 return getOffset();
>         }
>
>         public int getEnd(){
>                 return getPageSize() + getOffset();
>         }
>
>         /**
>          * Override this method to return the total number of records
>          */
>         public int getTotalNumberOfRows() {
>                 ArrayList lst = new ArrayList();
>
>                 // in your constructor you might do this
>                 try {
>                         JCS cache = JCS.getInstance("default");
>                         lst = (ArrayList)cache.get("caseSrchResults");
>             } catch ( CacheException e ) {
>                 e.printStackTrace();
>             } catch ( Exception e){
>                 e.printStackTrace();
>             }
>             if (lst == null) return 0;
>             else return lst.size();
>         }
> }
>
> --
> View this message in context: http://www.nabble.com/Objects-disappearing-from-cache-tp15547022p15547022.html
> Sent from the JCS - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jcs-users-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jcs-users-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jcs-users-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jcs-users-help@jakarta.apache.org