jakarta-jcs-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan Swaelens <jan.swael...@sofico.be>
Subject Re: Unable to get the stored Cache
Date Tue, 05 May 2009 07:36:43 GMT
The error you are getting is 'normal' (if you have a look at the JCS code 
you'll see that an error is raised when no elements are in the memory 
cache when a 'freeMemoryElements' operation is executed) and can be 
avoided by implementing this principle:

                        CompositeCache cc = CompositeCacheManager.
getInstance().getCache("myRegion1");
                        int memorySize = cc.getMemoryCache().getSize();
                        System.out.println("Entries in memory cache: " + 
memorySize);
                        if(memorySize>0) {
                                int elementsToFree = 1000;
                                jcs
.freeMemoryElements(memorySize<elementsToFree?memorySize:elementsToFree);
                        }

By checking the size of the memory cache before calling the 'free' method, 
you only free if it's actually needed and only as much as possible.

This brings us to another issue with your scenario, if you use the 
MaxObjects=0 setting all data is written to the disk cache immediatly, 
nothing will be stored in the memory cache anyway.

I also noticed that you are using 'myregion' to access the cache region, 
but your config file defines 'myRegion1'. The result of this is that you 
get a cache region based on the settings defined in the config file for 
the default region (which means that you can make changes in the config 
file for  'myRegion1' as much as you want, it will have no effect).
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message