-
Notifications
You must be signed in to change notification settings - Fork 1
feat: redis cache prefix version #114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
| import java.time.Duration; | ||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import org.springframework.beans.factory.annotation.Value; | ||
| import org.springframework.cache.annotation.CachingConfigurer; | ||
| import org.springframework.cache.annotation.EnableCaching; | ||
| import org.springframework.cache.interceptor.CacheErrorHandler; | ||
|
|
@@ -25,6 +26,9 @@ | |
| @EnableCaching | ||
| public class RedisConfig implements CachingConfigurer { | ||
|
|
||
| @Value("${app.cache.redis-prefix:oab:v2}") | ||
| private String cacheKeyPrefix; | ||
|
|
||
| @Override | ||
| public CacheErrorHandler errorHandler() { | ||
| return new RedisCacheErrorHandler(); | ||
|
|
@@ -38,14 +42,15 @@ public RedisCacheManager cacheManager(RedisConnectionFactory connectionFactory) | |
| .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); | ||
| objectMapper.activateDefaultTyping( | ||
| LaissezFaireSubTypeValidator.instance, | ||
| DefaultTyping.NON_FINAL, | ||
| DefaultTyping.EVERYTHING, | ||
| JsonTypeInfo.As.PROPERTY); | ||
|
Comment on lines
43
to
46
|
||
|
|
||
| GenericJackson2JsonRedisSerializer jsonSerializer = | ||
| new GenericJackson2JsonRedisSerializer(objectMapper); | ||
|
|
||
| RedisCacheConfiguration defaultConfig = | ||
| RedisCacheConfiguration.defaultCacheConfig() | ||
| .computePrefixWith(cacheName -> cacheKeyPrefix + ":" + cacheName + "::") | ||
| .entryTtl(Duration.ofMinutes(10)) | ||
| .serializeKeysWith( | ||
| RedisSerializationContext.SerializationPair.fromSerializer( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -146,6 +146,7 @@ elasticsearch: | |
|
|
||
| app: | ||
| cache: | ||
| redis-prefix: ${APP_CACHE_REDIS_PREFIX:oab:v2} # μ§λ ¬ν λ°©μ λ³κ²½ μ λ²μ μ νμ | ||
| warmup: | ||
| enabled: ${APP_CACHE_WARMUP_ENABLED:true} | ||
|
Comment on lines
147
to
151
|
||
| ranking-limit: ${APP_CACHE_WARMUP_RANKING_LIMIT:50} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default value for
app.cache.redis-prefixis defined both here in@Value(...:oab:v2)and inapplication.yml. Keeping defaults in two places makes future version bumps easy to miss; consider defining the default only in configuration (and reference${app.cache.redis-prefix}here without an inline default), or binding via@ConfigurationPropertiesfor a single source of truth.