001/*
002 * Copyright 2002-2019 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.cache;
018
019import java.util.Collection;
020
021/**
022 * Spring's central cache manager SPI.
023 *
024 * <p>Allows for retrieving named {@link Cache} regions.
025 *
026 * @author Costin Leau
027 * @author Sam Brannen
028 * @since 3.1
029 */
030public interface CacheManager {
031
032        /**
033         * Get the cache associated with the given name.
034         * <p>Note that the cache may be lazily created at runtime if the
035         * native provider supports it.
036         * @param name the cache identifier (must not be {@code null})
037         * @return the associated cache, or {@code null} if such a cache
038         * does not exist or could be not created
039         */
040        Cache getCache(String name);
041
042        /**
043         * Get a collection of the cache names known by this manager.
044         * @return the names of all caches known by the cache manager
045         */
046        Collection<String> getCacheNames();
047
048}