Configuring Caches
By default Caffeine is used for cache definitions which can be configured via application configuration. For example with application.yml
:
Cache Configuration Example
micronaut:
caches:
my-cache:
maximum-size: 20
The above example will configure a cache called “my-cache” with a maximum size of 20.
Naming Caches Names of caches under |
To configure a weigher to be used with the maximumWeight
configuration, create a bean that implements io.micronaut.caffeine.cache.Weigher
. To associate a given weigher with only a specific cache, annotate the bean with @Named(<cache name>)
. Weighers without a named qualifier will apply to all caches that don’t have a named weigher. If no beans are found, a default implementation will be used.
See the configuration reference for all available configuration options.