Browse Source

Document that CacheManager.getCache() may create a new Cache

Prior to this commit, it was unclear that an invocation of getCache()
might potentially create a new Cache.

This commit updates the Javadoc to point out that concrete CacheManager
implementations may choose to create a new Cache at runtime if the Cache
does not already exist.

Closes gh-23193
pull/23837/head
Sam Brannen 7 years ago
parent
commit
ac29e9de6a
  1. 15
      spring-context/src/main/java/org/springframework/cache/CacheManager.java

15
spring-context/src/main/java/org/springframework/cache/CacheManager.java vendored

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,23 +22,28 @@ import org.springframework.lang.Nullable; @@ -22,23 +22,28 @@ import org.springframework.lang.Nullable;
/**
* Spring's central cache manager SPI.
* Allows for retrieving named {@link Cache} regions.
*
* <p>Allows for retrieving named {@link Cache} regions.
*
* @author Costin Leau
* @author Sam Brannen
* @since 3.1
*/
public interface CacheManager {
/**
* Return the cache associated with the given name.
* Get the cache associated with the given name.
* <p>Note that the cache may be created at runtime if the native provider
* supports it.
* @param name the cache identifier (must not be {@code null})
* @return the associated cache, or {@code null} if none found
* @return the associated cache, or {@code null} if such a cache does not
* exist or could be not created
*/
@Nullable
Cache getCache(String name);
/**
* Return a collection of the cache names known by this manager.
* Get a collection of the cache names known by this manager.
* @return the names of all caches known by the cache manager
*/
Collection<String> getCacheNames();

Loading…
Cancel
Save