io.polaris.core.cache.AbstractCacheManager Maven / Gradle / Ivy
package io.polaris.core.cache;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/**
* @author Qt
* @since 1.8
*/
@SuppressWarnings("rawtypes")
public abstract class AbstractCacheManager implements ICacheManager {
private final ConcurrentMap cacheMap = new ConcurrentHashMap(16);
@Override
@SuppressWarnings("unchecked")
public ICache getCache(String name) {
ICache iCache = cacheMap.get(name);
if (iCache != null) {
return iCache;
}
synchronized (cacheMap) {
iCache = cacheMap.get(name);
if (iCache == null) {
iCache = createCache(name);
cacheMap.put(name, iCache);
}
return iCache;
}
}
protected ICache createCache(String name) {
return null;
}
}