All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.polaris.core.cache.AbstractCacheManager Maven / Gradle / Ivy

There is a newer version: 3.2.1
Show newest version
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;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy