notes/pl/java/libfws/cache/jcache/features/integration-spring-boot.txt
Ihar Hancharenka 5dff80e88e first
2023-03-27 16:52:17 +03:00

22 строки
1.0 KiB
Plaintext

@Bean
public JCacheManagerCustomizer cacheManagerCustomizer() {
return new JCacheManagerCustomizer() {
@Override
public void customize(CacheManager cacheManager) {
FactoryBuilder.SingletonFactory<MyCacheListener> listenerFactory =
new FactoryBuilder.SingletonFactory<MyCacheListener>(myCacheListener());
cacheManager.createCache("myCache", new MutableConfiguration<ResourceKey, ResourceValue>()
// there is no any memory-based config here available
.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.MINUTES, 1)))
.setStoreByValue(false)
.setStatisticsEnabled(true)
.addCacheEntryListenerConfiguration(
new MutableCacheEntryListenerConfiguration<ResourceKey, ResourceValue>(
listenerFactory, null, false, true
)));
}
};
}