Skip to content

Commit a800f21

Browse files
fix(cloud): add a CacheManager bean which allows null values #1610
1 parent 53f49b1 commit a800f21

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

server/odc-service/src/main/java/com/oceanbase/odc/config/CacheConfiguration.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.springframework.context.annotation.Bean;
2727
import org.springframework.context.annotation.Configuration;
2828
import org.springframework.context.annotation.Lazy;
29+
import org.springframework.context.annotation.Primary;
2930

3031
import com.github.benmanes.caffeine.cache.Caffeine;
3132
import com.github.benmanes.caffeine.cache.LoadingCache;
@@ -79,6 +80,7 @@ public LoadingCache<Long, List<Rule>> rulesetId2RulesCache() {
7980
}
8081

8182
@Bean("defaultCacheManager")
83+
@Primary
8284
public CacheManager defaultCacheManager() {
8385
Caffeine<Object, Object> caffeine = Caffeine.newBuilder().maximumSize(1000).expireAfterWrite(
8486
Duration.ofSeconds(600));
@@ -88,4 +90,14 @@ public CacheManager defaultCacheManager() {
8890
return cacheManager;
8991
}
9092

93+
@Bean("allowNullCacheManager")
94+
public CacheManager allowNullCacheManager() {
95+
Caffeine<Object, Object> caffeine = Caffeine.newBuilder().maximumSize(1000).expireAfterWrite(
96+
Duration.ofSeconds(600));
97+
CaffeineCacheManager cacheManager = new CaffeineCacheManager();
98+
cacheManager.setAllowNullValues(true);
99+
cacheManager.setCaffeine(caffeine);
100+
return cacheManager;
101+
}
102+
91103
}

0 commit comments

Comments
 (0)