Memory and disk cache with JCS 1.3

trying to implement memory and disk cache with JCS v1.3, got information from docs and series of threads here on stackoverflow but still has no solution.
My test is simple:

  • load JCS;
  • save the item to the cache;
  • Terminate JCS.
    After that I want:
  • reload JCS:
  • get the same item from the cache.

I am getting null here. I can see both files region.data and region.key when I build, but for some reason I cannot get the item back, despite debugging and looking for the correct key in the auxiliary disk cache, there is no value in it and hence get returns nothing to me.

Can anyone help me?

Code:

private void performSimplerObjectPersistingInMemoryAndDisk(String configFile, String expected) throws Exception {

                    String key = "key", value = "value"; 
        JCS.setConfigFilename(configFile);
        JCS cache = JCS.getInstance("OUR_REGION");
        cache.put(key, value);
        Thread.sleep(5000);
        Assert.assertNotNull(cache.get(key));
        Assert.assertEquals(value, cache.get(key));
        System.out.println(cache.getStats());
        CompositeCacheManager.getInstance().shutDown();
        Thread.sleep(5000);
        JCS.setConfigFilename(configFile);
        cache = JCS.getInstance("OUR_REGION");
        Assert.assertEquals(expected, cache.get(key));
        System.out.println(cache.getStats());
    }

      

JCS config:

# DEFAULT CACHE REGION
jcs.default=DISK_REGION
jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.default.cacheattributes.MaxObjects=1000
jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
jcs.default.cacheattributes.DiskUsagePatternName=UPDATE
jcs.default.elementattributes=org.apache.jcs.engine.ElementAttributes
jcs.default.elementattributes.IsSpool=true

jcs.region.OUR_REGION=DISK_REGION
jcs.region.OUR_REGION.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.region.OUR_REGION.cacheattributes.MaxObjects=0
jcs.region.OUR_REGION.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
jcs.region.OUR_REGION.cacheattributes.UseMemoryShrinker=true
jcs.region.OUR_REGION.cacheattributes.MaxMemoryIdleTimeSeconds=3600
jcs.region.OUR_REGION.cacheattributes.ShrinkerIntervalSeconds=60
jcs.region.OUR_REGION.cacheattributes.MaxSpoolPerRun=500
jcs.region.OUR_REGION.elementattributes=org.apache.jcs.engine.ElementAttributes
jcs.region.OUR_REGION.elementattributes.IsEternal=false

jcs.auxiliary.DISK_REGION=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheFactory
jcs.auxiliary.DISK_REGION.attributes=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes
jcs.auxiliary.DISK_REGION.attributes.DiskPath=/tmp/jcs/cache
jcs.auxiliary.DISK_REGION.attributes.maxKeySize=100000

      

+3
java caching offline-caching jcs


source to share


No one has answered this question yet

Check out similar questions:

3044
Making a memory leak with Java
1554
Disable Chrome cache for website development
1398
How do we control web page caching in all browsers?
1001
Is Safari iOS 6 caching $ .ajax results?
951
How do I force the browser to reload the cached CSS / JS files?
683
What is "caching" code?
591
What's the difference between Cache-Control: max-age = 0 and no-cache?
2
JCS 1.3 - cache preload from disk
1
JCS 2.2 - Ability to write / eject from disk, but not from memory
0
Oracle Coherence - data change is not reflected in the cache



All Articles
Loading...
X
Show
Funny
Dev
Pics