Finds caches by name: the object the cache annotations ask for the cache they name.
Every application with the starter has one: unless the application
declares its own, the starter creates an InMemoryCacheManager from
the spring.cache.* properties. Declare a CacheManager bean to choose
the caches yourself (fixed names, your own storage, a mix); the
starter's one then steps aside and spring.cache.* no longer applies.
Inject it to reach the caches by hand.
// Only these two caches exist; @Cacheable('other') fails the call.
@Configuration()
class CacheSetup {
@Bean()
CacheManager cacheManager() =>
InMemoryCacheManager(cacheNames: ['books', 'authors']);
}
Spring (Java):
@Bean
CacheManager cacheManager() {
return new ConcurrentMapCacheManager("books", "authors");
}
- Implementers
Properties
-
cacheNames
→ Iterable<
String> -
The names of the caches the manager holds so far (caches created on
demand appear once they were asked for).
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
getCache(
String name) → Cache? -
The cache named
name. A manager that creates caches on demand creates it now; otherwise an unknown name givesnull. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited