org.springframework.cache.support

## 类 CompositeCacheManager

- java.lang.Object
- - org.springframework.cache.support.CompositeCacheManager

- 所有已实现的接口:
    org.springframework.beans.factory.InitializingBean, CacheManager

      public class CompositeCacheManager
      extends Object
      implements CacheManager, org.springframework.beans.factory.InitializingBean

  Composite `CacheManager` implementation that iterates over a given collection of delegate `CacheManager` instances.

  Allows `NoOpCacheManager` to be automatically added to the end of the list for handling cache declarations without a backing store. Otherwise, any custom `CacheManager` may play that role of the last delegate as well, lazily creating cache regions for any requested name.

  Note: Regular CacheManagers that this composite manager delegates to need to return `null` from `getCache(String)` if they are unaware of the specified cache name, allowing for iteration to the next delegate in line. However, most `CacheManager` implementations fall back to lazy creation of named caches once requested; check out the specific configuration details for a 'static' mode with fixed cache names, if available.

  从以下版本开始:
    3.1
  作者:
    Costin Leau, Juergen Hoeller
  另请参阅:
    `setFallbackToNoOpCache(boolean)`, `ConcurrentMapCacheManager.setCacheNames(java.util.Collection<java.lang.String>)`

- - ### 构造器概要

    构造器
    构造器和说明
    `CompositeCacheManager()` Construct an empty CompositeCacheManager, with delegate CacheManagers to be added via the `"cacheManagers"` property.
    `CompositeCacheManager(CacheManager... cacheManagers)` Construct a CompositeCacheManager from the given delegate CacheManagers.

  - ### 方法概要

    所有方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `void` | `afterPropertiesSet()`
    `Cache` | `getCache(String name)` Return the cache associated with the given name.
    `Collection<String>` | `getCacheNames()` Return a collection of the cache names known by this manager.
    `void` | `setCacheManagers(Collection<CacheManager> cacheManagers)` Specify the CacheManagers to delegate to.
    `void` | `setFallbackToNoOpCache(boolean fallbackToNoOpCache)` Indicate whether a `NoOpCacheManager` should be added at the end of the delegate list.

    - ### 从类继承的方法 java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 构造器详细资料

    - #### CompositeCacheManager

          public CompositeCacheManager()

      Construct an empty CompositeCacheManager, with delegate CacheManagers to be added via the `"cacheManagers"` property.

    - #### CompositeCacheManager

          public CompositeCacheManager(CacheManager... cacheManagers)

      Construct a CompositeCacheManager from the given delegate CacheManagers.
      参数:
        `cacheManagers` - the CacheManagers to delegate to

  - ### 方法详细资料

    - #### setCacheManagers

          public void setCacheManagers(Collection<CacheManager> cacheManagers)

      Specify the CacheManagers to delegate to.

    - #### setFallbackToNoOpCache

          public void setFallbackToNoOpCache(boolean fallbackToNoOpCache)

      Indicate whether a `NoOpCacheManager` should be added at the end of the delegate list. In this case, any `getCache` requests not handled by the configured CacheManagers will be automatically handled by the `NoOpCacheManager` (and hence never return `null`).

    - #### afterPropertiesSet

          public void afterPropertiesSet()

      指定者:
        `afterPropertiesSet` 在接口中 `org.springframework.beans.factory.InitializingBean`

    - #### getCache

          @Nullable
          public Cache getCache(String name)

      从接口复制的说明: `CacheManager`
      Return the cache associated with the given name.
      指定者:
        `getCache` 在接口中 `CacheManager`
      参数:
        `name` - the cache identifier (must not be `null`)
      返回:
        the associated cache, or `null` if none found

    - #### getCacheNames

          public Collection<String> getCacheNames()

      从接口复制的说明: `CacheManager`
      Return a collection of the cache names known by this manager.
      指定者:
        `getCacheNames` 在接口中 `CacheManager`
      返回:
        the names of all caches known by the cache manager