org.springframework.cache.support.NoOpCache Java Examples

The following examples show how to use org.springframework.cache.support.NoOpCache. 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: MultiCacheManager.java    From gateway-helper with Apache License 2.0 6 votes vote down vote up
private Cache createMultiCacheByProperties(String name) {
    MultiCacheProperties.Cache config = properties.getCaches().get(name);
    if (config == null) {
        config = new MultiCacheProperties.Cache();
    }
    if (config.isL1Enabled() && config.isL2Enabled() && l1CacheManager != null && l2CacheManager != null) {
        return new MultiAllCache(name, l1CacheManager.getL1Cache(name, config.getL1Spec()),
                l2CacheManager.getL2Cache(name, config.getL2Spec()));
    }
    if (config.isL1Enabled() && config.isL2Enabled() && l1CacheManager != null) {
        return new MultiL1Cache(name, l1CacheManager.getL1Cache(name, config.getL1Spec()));
    }
    if (config.isL1Enabled() && config.isL2Enabled() && l2CacheManager != null) {
        return new MultiL2Cache(name, l2CacheManager.getL2Cache(name, config.getL2Spec()));
    }
    if (config.isL1Enabled() && !config.isL2Enabled() && l1CacheManager != null) {
        return new MultiL1Cache(name, l1CacheManager.getL1Cache(name, config.getL1Spec()));
    }
    if (!config.isL1Enabled() && config.isL2Enabled() && l2CacheManager != null) {
        return new MultiL2Cache(name, l2CacheManager.getL2Cache(name, config.getL2Spec()));
    }
    return new NoOpCache(name);
}
 
Example #2
Source File: MultiCacheManager.java    From api-gateway-old with Apache License 2.0 6 votes vote down vote up
private Cache createMultiCacheByProperties(String name) {
    MultiCacheProperties.Cache config = properties.getCaches().get(name);
    if (config == null) {
        config = new MultiCacheProperties.Cache();
    }
    if (config.isL1Enabled() && config.isL2Enabled() && l1CacheManager != null && l2CacheManager != null) {
        return new MultiAllCache(name, l1CacheManager.getL1Cache(name, config.getL1Spec()),
                l2CacheManager.getL2Cache(name, config.getL2Spec()));
    }
    if (config.isL1Enabled() && config.isL2Enabled() && l1CacheManager != null) {
        return new MultiL1Cache(name, l1CacheManager.getL1Cache(name, config.getL1Spec()));
    }
    if (config.isL1Enabled() && config.isL2Enabled() && l2CacheManager != null) {
        return new MultiL2Cache(name, l2CacheManager.getL2Cache(name, config.getL2Spec()));
    }
    if (config.isL1Enabled() && !config.isL2Enabled() && l1CacheManager != null) {
        return new MultiL1Cache(name, l1CacheManager.getL1Cache(name, config.getL1Spec()));
    }
    if (!config.isL1Enabled() && config.isL2Enabled() && l2CacheManager != null) {
        return new MultiL2Cache(name, l2CacheManager.getL2Cache(name, config.getL2Spec()));
    }
    return new NoOpCache(name);
}
 
Example #3
Source File: ModifiedClientCacheTemplate.java    From n2o-framework with Apache License 2.0 5 votes vote down vote up
protected Cache getCache() {
    Cache cache = cacheManager.getCache(cacheRegion);
    if (cache == null) {
        logger.warn("Cannot find cache named [" + cacheRegion + "] for CacheTemplate");
        return new NoOpCache(cacheRegion);
    }
    return cache;
}
 
Example #4
Source File: InitializrAutoConfiguration.java    From initializr with Apache License 2.0 5 votes vote down vote up
private Cache determineCache(Environment environment, CacheManager cacheManager) {
	if (cacheManager != null) {
		Binder binder = Binder.get(environment);
		boolean cache = binder.bind("spring.mustache.cache", Boolean.class).orElse(true);
		if (cache) {
			return cacheManager.getCache("initializr.templates");
		}
	}
	return new NoOpCache("templates");
}
 
Example #5
Source File: NoOpCacheTemplate.java    From n2o-framework with Apache License 2.0 4 votes vote down vote up
@Override
public T execute(String cacheRegion, K key, CacheCallback<T> callback) {
    return handleCache(key, callback, new NoOpCache(cacheRegion));
}