-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathCacheConfig.java
More file actions
39 lines (32 loc) · 1.2 KB
/
Copy pathCacheConfig.java
File metadata and controls
39 lines (32 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package com.ceos23.spring_boot.config;
import com.github.benmanes.caffeine.cache.Caffeine;
import org.springframework.cache.CacheManager;
import org.springframework.cache.caffeine.CaffeineCache;
import org.springframework.cache.support.SimpleCacheManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.time.Duration;
import java.util.List;
@Configuration
public class CacheConfig {
@Bean
public CacheManager cacheManager() {
CaffeineCache movieAllCache = new CaffeineCache(
"movieAll",
Caffeine.newBuilder()
.expireAfterWrite(Duration.ofMinutes(10))
.maximumSize(1)
.build()
);
CaffeineCache movieCache = new CaffeineCache(
"movie",
Caffeine.newBuilder()
.expireAfterWrite(Duration.ofMinutes(10))
.maximumSize(100)
.build()
);
SimpleCacheManager cacheManager = new SimpleCacheManager();
cacheManager.setCaches(List.of(movieAllCache, movieCache));
return cacheManager;
}
}