Java Code Examples for net.sf.ehcache.CacheManager#addCacheIfAbsent()

The following examples show how to use net.sf.ehcache.CacheManager#addCacheIfAbsent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EhcacheFactory.java    From MeetingFilm with Apache License 2.0 6 votes vote down vote up
static Cache getOrAddCache(String cacheName) {
	CacheManager cacheManager = getCacheManager();
	Cache cache = cacheManager.getCache(cacheName);
	if (cache == null) {
		synchronized(locker) {
			cache = cacheManager.getCache(cacheName);
			if (cache == null) {
				log.warn("无法找到缓存 [" + cacheName + "]的配置, 使用默认配置.");
				cacheManager.addCacheIfAbsent(cacheName);
				cache = cacheManager.getCache(cacheName);
				log.debug("缓存 [" + cacheName + "] 启动.");
			}
		}
	}
	return cache;
}
 
Example 2
Source File: EhcacheFactory.java    From springboot-admin with Apache License 2.0 6 votes vote down vote up
static Cache getOrAddCache(String cacheName) {
	CacheManager cacheManager = getCacheManager();
	Cache cache = cacheManager.getCache(cacheName);
	if (cache == null) {
		synchronized(locker) {
			cache = cacheManager.getCache(cacheName);
			if (cache == null) {
				log.warn("无法找到缓存 [" + cacheName + "]的配置, 使用默认配置.");
				cacheManager.addCacheIfAbsent(cacheName);
				cache = cacheManager.getCache(cacheName);
				log.debug("缓存 [" + cacheName + "] 启动.");
			}
		}
	}
	return cache;
}
 
Example 3
Source File: CacheUtil.java    From WebStack-Guns with MIT License 5 votes vote down vote up
private static Cache getOrAddCache(String cacheName) {
    CacheManager cacheManager = SpringContextHolder.getBean(CacheManager.class);
    Cache cache = cacheManager.getCache(cacheName);
    if (cache == null) {
        synchronized (LOCKER) {
            cache = cacheManager.getCache(cacheName);
            if (cache == null) {
                cacheManager.addCacheIfAbsent(cacheName);
                cache = cacheManager.getCache(cacheName);
            }
        }
    }
    return cache;
}
 
Example 4
Source File: Output.java    From red5-io with Apache License 2.0 5 votes vote down vote up
private static CacheManager constructDefault() {
    CacheManager manager = CacheManager.getInstance();
    manager.addCacheIfAbsent("org.red5.io.amf.Output.stringCache");
    manager.addCacheIfAbsent("org.red5.io.amf.Output.getterCache");
    manager.addCacheIfAbsent("org.red5.io.amf.Output.fieldCache");
    manager.addCacheIfAbsent("org.red5.io.amf.Output.serializeCache");
    return manager;
}