我正在使用Java& amp; JCS
虽然我发现jcs.get非常慢,而jcs.put非常快。
我的代码是这样的:
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);
}
}
...
我的属性文件
# 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
任何提示都会非常感激
谢谢!