1

I am working on a project using Java & JCS

While I found that jcs.get is really slow while jcs.put is pretty fast.

My code is something like these:

Properties cacheConf = new Properties();
final String classPath = Thread.currentThread().getContextClassLoader().getResource("").getPath();

try{
    cacheConf.load(new BufferedReader(new FileReader(classPath + "/cache.properties")));
    CompositeCacheManager ccm = CompositeCacheManager.getUnconfiguredInstance();
ccm.configure(cacheConf);

    ICompositeCacheAttributes cattr = new CompositeCacheAttributes();
    cattr.setMaxObjects( 100000 );
    JCS cache = JCS.getInstance("default");

    for(int i=0;i<10000;i++){
        cache.put("my"+i, i);     //fast
        Object o = cache.get("my"+i);  //very slow about 1 sec/query
        System.out.println(o);
    }
}
...

My property file

# DEFAULT CACHE REGION
jcs.default=
jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.default.cacheattributes.MaxObjects=2000000
jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLifeSeconds=3600
jcs.default.elementattributes.IdleTime=1800
jcs.default.elementattributes.IsSpool=true
jcs.default.elementattributes.IsRemote=true
jcs.default.elementattributes.IsLateral=true

Any hint will be very appreciate

Thank you!

Soyoes
  • 940
  • 11
  • 16
  • what is the value of "k", can you attempt to get the key after you have finished inserting into the cache to see if performance improves? – Greg Nov 15 '13 at 07:20
  • thank you @Greg, what I suppose to get is "my"+i, I just fixed my question. And I ve to make sure this operation is synchronized – Soyoes Nov 15 '13 at 07:28

0 Answers0