SimpleCacheManager class final
A CacheManager that holds a fixed list of caches you build yourself.
It is the way to put caches of your own (or a mix of yours and
InMemoryCaches) behind the annotations. It never creates a cache: an
unknown name gives null, so @Cacheable('other') fails the call with
"Cannot find cache named 'other'". The starter also uses it for
spring.cache.type=generic, with the Cache beans of the application.
@Configuration()
class CacheSetup {
@Bean()
CacheManager cacheManager(KeyValueStore store) => SimpleCacheManager([
StoreCache('books', store), // kept across restarts
InMemoryCache('prices'), // in memory
]);
}
Spring (Java):
@Bean
CacheManager cacheManager(KeyValueStore store) {
var manager = new SimpleCacheManager();
manager.setCaches(List.of(new StoreCache("books", store),
new ConcurrentMapCache("prices")));
return manager;
}
- Implemented types
Constructors
-
SimpleCacheManager(Iterable<
Cache> caches) -
A manager of
caches, found by their Cache.name; of two caches with the same name the later one wins.
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 setteroverride
- 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.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited