Top Description Methods
org.springframework.cache.annotation

public Interface CachingConfigurer

Known Direct Implementers
org.springframework.cache.annotation.CachingConfigurerSupport
Imports
org.springframework.cache.CacheManager, org.springframework.cache.interceptor.CacheErrorHandler, .CacheResolver, .KeyGenerator, org.springframework.lang.Nullable

Interface to be implemented by @Configuration classes annotated with @EnableCaching that wish or need to specify explicitly how caches are resolved and how keys are generated for annotation-driven cache management.

See @EnableCaching for general examples and context; see cacheManager(), cacheResolver() and keyGenerator() for detailed instructions.

Authors
Chris Beams, Stephane Nicoll
Since
3.1
See Also
EnableCaching

Method Summary

Modifier and TypeMethod and Description
public default CacheManager
cacheManager()

Return the cache manager bean to use for annotation-driven cache management.

public default CacheResolver
cacheResolver()

Return the CacheResolver bean to use to resolve regular caches for annotation-driven cache management.

public default CacheErrorHandler
errorHandler()

Return the CacheErrorHandler to use to handle cache-related errors.

public default KeyGenerator
keyGenerator()

Return the key generator bean to use for annotation-driven cache management.

Method Detail

cacheManagerback to summary
public default CacheManager cacheManager()

Return the cache manager bean to use for annotation-driven cache management. A default CacheResolver will be initialized behind the scenes with this cache manager. For more fine-grained management of the cache resolution, consider setting the CacheResolver directly.

Implementations must explicitly declare @Bean, e.g.

@Configuration
@EnableCaching
public class AppConfig implements CachingConfigurer {
    @Bean // important!
    @Override
    public CacheManager cacheManager() {
        // configure and return CacheManager instance
    }
    // ...
}
See @EnableCaching for more complete examples.
Annotations
@Nullable
cacheResolverback to summary
public default CacheResolver cacheResolver()

Return the CacheResolver bean to use to resolve regular caches for annotation-driven cache management. This is an alternative and more powerful option of specifying the CacheManager to use.

If both a cacheManager() and #cacheResolver() are set, the cache manager is ignored.

Implementations must explicitly declare @Bean, e.g.

@Configuration
@EnableCaching
public class AppConfig implements CachingConfigurer {
    @Bean // important!
    @Override
    public CacheResolver cacheResolver() {
        // configure and return CacheResolver instance
    }
    // ...
}
See EnableCaching for more complete examples.
Annotations
@Nullable
errorHandlerback to summary
public default CacheErrorHandler errorHandler()

Return the CacheErrorHandler to use to handle cache-related errors.

By default,org.springframework.cache.interceptor.SimpleCacheErrorHandler is used and simply throws the exception back at the client.

Implementations must explicitly declare @Bean, e.g.

@Configuration
@EnableCaching
public class AppConfig implements CachingConfigurer {
    @Bean // important!
    @Override
    public CacheErrorHandler errorHandler() {
        // configure and return CacheErrorHandler instance
    }
    // ...
}
See @EnableCaching for more complete examples.
Annotations
@Nullable
keyGeneratorback to summary
public default KeyGenerator keyGenerator()

Return the key generator bean to use for annotation-driven cache management. Implementations must explicitly declare @Bean, e.g.

@Configuration
@EnableCaching
public class AppConfig implements CachingConfigurer {
    @Bean // important!
    @Override
    public KeyGenerator keyGenerator() {
        // configure and return KeyGenerator instance
    }
    // ...
}
See @EnableCaching for more complete examples.
Annotations
@Nullable