I am trying to use JCS 1.3 to create a eternal disk cache. I want the cache to be able to shut down, and then reload itself from the disk the next time I use it. I have a lot of data that I am going to be populating from a DB that takes a long time to run and it is going to be much faster if the cache just reloads off of the disk. I have tried reading through the JCS documentation and using their configuration examples to get going, but no success so far. Here is the configuration I am using
##############################################################
##### Default Region Configuration
jcs.default=DC
jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.default.cacheattributes.MaxObjects=100
jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
jcs.default.cacheattributes.DiskUsagePatternName=UPDATE
##############################################################
##### CACHE REGIONS
jcs.region.myRegion1=DC
jcs.region.myRegion1.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.region.myRegion1.cacheattributes.MaxObjects=1000
jcs.region.myRegion1.cacheattributes.DiskUsagePatternName=UPDATE
jcs.region.myRegion1.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
jcs.region.myRegion1.elementattributes.IsEternal=true
##############################################################
##### AUXILIARY CACHES
# Indexed Disk Cache
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=f:/eh cache
jcs.auxiliary.DC.attributes.MaxPurgatorySize=10000
jcs.auxiliary.DC.attributes.MaxKeySize=10000
jcs.auxiliary.DC.attributes.OptimizeAtRemoveCount=300000
jcs.auxiliary.DC.attributes.OptimizeOnShutdown=true
jcs.auxiliary.DC.attributes.MaxRecycleBinSize=7500
Here is a very simple test I am running to make sure my configuration is correct.
JCS cache = JCS.getInstance("myRegion1"); cache.put("key", "my value");
System.out.println("Value In Cache After Put [" + cache.get("key") + "]");
Thread.sleep(5000);
CompositeCacheManager.getInstance().shutDown();
cache = JCS.getInstance("myRegion1");
System.out.println("Value In Cache After Reload [" + cache.get("key") + "]");
Here is what I get in my output:
Value In Cache After Put [my value]
Value In Cache After Reload [null]
Would someone be able to point me in the right direction on this one? Not sure if it is an issue in my configuration, or something that needs to be done in the code to tell it to refresh from disk.