新增外部包:
jcs-1.3.jar
concurrent-10.3.jar
cache.cff
# optional region "myCache" specific configuration settings jcs.region.myCache= jcs.region.myCache.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes jcs.region.myCache.cacheattributes.MaxObjects=123456 jcs.region.myCache.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache jcs.region.myCache.cacheattributes.UseMemoryShrinker=true jcs.region.myCache.cacheattributes.ShrinkerIntervalSeconds=30 jcs.region.myCache.cacheattributes.MaxMemoryIdleTimeSeconds=300 jcs.region.myCache.cacheattributes.MaxSpoolPerRun=100 jcs.region.myCache.elementattributes=org.apache.jcs.engine.ElementAttributes jcs.region.myCache.elementattributes.IsEternal=false jcs.region.myCache.elementattributes.MaxLifeSeconds=60000 jcs.region.myCache.elementattributes.IsSpool=true jcs.region.myCache.elementattributes.IsLateral=true jcs.region.myCache.elementattributes.IsRemote=true
用法:
JCS myCache = null; Object key=""; Object value=""; try { myCache = JCS.getInstance("myCache"); //存放到快取中 myCache.put(key,value); //從快取中提取key的所對應的值 value = myCache.get(key); } catch (Exception e) { e.printStackTrace(); }