use of org.springframework.boot.autoconfigure.orm.jpa.HibernatePropertiesCustomizer in project tutorials by jhkim105.
the class CacheConfig method hibernatePropertiesCustomizer.
@Bean
public HibernatePropertiesCustomizer hibernatePropertiesCustomizer() {
CachingProvider cachingProvider = new EhcacheCachingProvider();
CacheManager cacheManager = cachingProvider.getCacheManager();
MutableConfiguration<String, Object> configuration = new MutableConfiguration<>();
configuration.setStoreByValue(false).setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.SECONDS, 1)));
cacheManager.createCache("user", configuration);
return hibernateProperties -> hibernateProperties.put(ConfigSettings.CACHE_MANAGER, cacheManager);
}
Aggregations