com.holmos.cache.store.CacheStoreFactory Maven / Gradle / Ivy
package com.holmos.cache.store;
import com.holmos.cache.config.CacheConfigComponent;
import com.holmos.cache.config.MemoryCacheConfigComponent;
import com.holmos.cache.store.impl.BigMemoryCacheStore;
import com.holmos.cache.store.impl.DiskCacheStore;
import com.holmos.cache.store.impl.MemoryCacheStore;
/**
* 存储器工厂
*
* @author: 吴银龙([email protected])
* @version: 2013-3-19 下午12:29:32
*/
public class CacheStoreFactory {
private static CacheStoreFactory cacheStoreFactory = new CacheStoreFactory();
private CacheStoreFactory(){}
public static CacheStoreFactory getInstance(){
return cacheStoreFactory;
}
/**
* 根据 存储器的名称(类型)来获得存储器实例,这是holmos-wasten平台所用的存储器创建工厂,可以自己扩展,
* 这个工厂的调用在相应的Cache类里面
*
* */
public CacheStore getCacheStore(CacheStoreMedia storeMedia,CacheConfigComponent configComponent){
if(storeMedia == CacheStoreMedia.MEMORY){
return new MemoryCacheStore((MemoryCacheConfigComponent) configComponent);
}else if(storeMedia == CacheStoreMedia.BIGMEMORY){
return new BigMemoryCacheStore();
}else if(storeMedia == CacheStoreMedia.DISK){
return new DiskCacheStore();
}else {
return null;
}
}
}