This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package ru.soune.nocopy.configuration;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.cache.caffeine.CaffeineCacheManager;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Configuration
|
||||
@EnableCaching
|
||||
public class CacheConfig {
|
||||
|
||||
@Bean
|
||||
public CacheManager cacheManager() {
|
||||
CaffeineCacheManager cacheManager = new CaffeineCacheManager(
|
||||
"imageSearch", "parsedImages");
|
||||
|
||||
cacheManager.setCaffeine(Caffeine.newBuilder()
|
||||
.maximumSize(10000)
|
||||
.expireAfterWrite(1, TimeUnit.HOURS)
|
||||
.recordStats()
|
||||
);
|
||||
|
||||
return cacheManager;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user