return new CacheWrapper(cache);
}catch(CacheException e){
return null;
}
}
/**
* 创建缓存对象
* @param cacheName
*/
private static void createHashMapWrapper(String cacheName){
hashMapWrapper.put(cacheName, createCacheWrapper(cacheName));
}
/**
* 初始化缓存对象
*/
public static void initCache(){
logger.debug("By Start initCache Method, We create all the Cache Object");
createHashMapWrapper("coolBoyCache");
// createHashMapWrapper("beautifulGirl");
}
}
5.3创建测试类TestCache,测试刚才的缓存对象。
[java]
package com.favccxx.favjcs.web;
import com.favccxx.favjcs.CacheFactory;
public class TestCache {
/**
* @param args
*/
public static void main(String[] args) {
CacheFactory.initCache();
CacheFactory.getCacheWrapper("coolBoy");
}
}
package com.favccxx.favjcs.web;
import com.favccxx.favjcs.CacheFactory;
public class TestCache {
/**
* @param args
*/
public static void main(String[] args) {
CacheFactory.initCache();
CacheFactory.getCacheWrapper("coolBoy");
}
}