Java Code Examples for org.springframework.cache.Cache#getName()

The following examples show how to use org.springframework.cache.Cache#getName() . 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: AbstractGenericCacheWrapper.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected <O> void manage(String key, O object, Action operation) {
    if (null == object) {
        return;
    }
    Cache cache = this.getCache();
    List<String> codes = (List<String>) this.get(cache, this.getCodesCacheKey(), List.class);
    if (Action.ADD.equals(operation)) {
        if (!codes.contains(key)) {
            codes.add(key);
            cache.put(this.getCodesCacheKey(), codes);
        }
        cache.put(this.getCacheKeyPrefix() + key, object);
    } else if (Action.UPDATE.equals(operation)) {
        if (!codes.contains(key)) {
            throw new CacheItemNotFoundException(key, cache.getName());
        }
        cache.put(this.getCacheKeyPrefix() + key, object);
    } else if (Action.DELETE.equals(operation)) {
        codes.remove(key);
        cache.evict(this.getCacheKeyPrefix() + key);
        cache.put(this.getCodesCacheKey(), codes);
    }
}
 
Example 2
Source File: AbstractCacheManager.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Dynamically register an additional Cache with this manager.
 * @param cache the Cache to register
 * @deprecated as of Spring 4.3, in favor of {@link #getMissingCache(String)}
 */
@Deprecated
protected final void addCache(Cache cache) {
	String name = cache.getName();
	synchronized (this.cacheMap) {
		if (this.cacheMap.put(name, decorateCache(cache)) == null) {
			updateCacheNames(name);
		}
	}
}
 
Example 3
Source File: AbstractCacheManager.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Dynamically register an additional Cache with this manager.
 * @param cache the Cache to register
 * @deprecated as of Spring 4.3, in favor of {@link #getMissingCache(String)}
 */
@Deprecated
protected final void addCache(Cache cache) {
	String name = cache.getName();
	synchronized (this.cacheMap) {
		if (this.cacheMap.put(name, decorateCache(cache)) == null) {
			updateCacheNames(name);
		}
	}
}
 
Example 4
Source File: AbstractCacheManager.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Dynamically register an additional Cache with this manager.
 * @param cache the Cache to register
 * @deprecated as of Spring 4.3, in favor of {@link #getMissingCache(String)}
 */
@Deprecated
protected final void addCache(Cache cache) {
	String name = cache.getName();
	synchronized (this.cacheMap) {
		if (this.cacheMap.put(name, decorateCache(cache)) == null) {
			updateCacheNames(name);
		}
	}
}
 
Example 5
Source File: AbstractCacheManager.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Dynamically register an additional Cache with this manager.
 * @param cache the Cache to register
 */
protected final void addCache(Cache cache) {
	String name = cache.getName();
	synchronized (this.cacheMap) {
		if (this.cacheMap.put(name, decorateCache(cache)) == null) {
			updateCacheNames(name);
		}
	}
}
 
Example 6
Source File: DockerCacheInvalidator.java    From haven-platform with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void init(Cache cache, Map<String, String> args) {
    String name = cache.getName();
    if(!DockerService.CACHE_CONTAINER_DETAILS.equals(name)) {
        return;
    }
    Consumer<DockerLogEvent> listener = this.listeners.computeIfAbsent(name, (n) -> this.makeInvalidator(cache));
    logEvents.subscribe(listener);
}
 
Example 7
Source File: MgmtSystemManagementResource.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
private MgmtSystemCache cacheRest(final Cache cache) {
    final Object nativeCache = cache.getNativeCache();
    if (nativeCache instanceof com.google.common.cache.Cache) {
        return guavaCache(cache, nativeCache);
    } else {
        return new MgmtSystemCache(cache.getName(), Collections.emptyList());
    }
}