From 9f2cb3e276e1513b5f93ff9a7e1621d98a3f485d Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 25 Jul 2016 17:47:11 +0200 Subject: [PATCH] Keep deprecated addCache method (e.g. for Spring Data Redis) Issue: SPR-14430 --- .../cache/support/AbstractCacheManager.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spring-context/src/main/java/org/springframework/cache/support/AbstractCacheManager.java b/spring-context/src/main/java/org/springframework/cache/support/AbstractCacheManager.java index 4bb80ca4a1..a05aa254a4 100644 --- a/spring-context/src/main/java/org/springframework/cache/support/AbstractCacheManager.java +++ b/spring-context/src/main/java/org/springframework/cache/support/AbstractCacheManager.java @@ -128,6 +128,21 @@ public abstract class AbstractCacheManager implements CacheManager, Initializing return this.cacheMap.get(name); } + /** + * 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); + } + } + } + /** * Update the exposed {@link #cacheNames} set with the given name. *

This will always be called within a full {@link #cacheMap} lock