Java缓存--JCS

添加外部包:

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();
    }        

 

 

posted @ 2013-06-19 15:54  qingyezhu  阅读(773)  评论(0编辑  收藏  举报