Skip to content

Commit

Permalink
fix : redis cache 관련 테스트 수정 (#23)
Browse files Browse the repository at this point in the history
* fix : redis cache 관련 테스트 주석 처리

* style : spotless apply

* fix : redis cache object mapper 수정
  • Loading branch information
ImNM authored May 13, 2023
1 parent 4a7dccd commit 5360d30
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class EventPublisherAspect : ApplicationEventPublisherAware {
private val appliedLocal: ThreadLocal<Boolean> = ThreadLocal.withInitial { false }

@Around("@annotation(org.springframework.transaction.annotation.Transactional)")
fun handleEvent(joinPoint: ProceedingJoinPoint): Any {
fun handleEvent(joinPoint: ProceedingJoinPoint): Any? {
val appliedValue = appliedLocal.get()
// nested를 쓰는이유
// 트랜잭션 안에 트랜잭션이 또있는 경우대비
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.depromeet.whatnow.config.redis

import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.jsontype.BasicPolymorphicTypeValidator
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import org.springframework.cache.CacheManager
import org.springframework.cache.annotation.EnableCaching
import org.springframework.context.annotation.Bean
Expand All @@ -16,6 +19,14 @@ import java.time.Duration
@Configuration
class RedisCacheConfig {

val objectMapper: ObjectMapper = jacksonObjectMapper()
.activateDefaultTyping(
BasicPolymorphicTypeValidator.builder()
.allowIfBaseType(Any::class.java)
.build(),
ObjectMapper.DefaultTyping.EVERYTHING,
)

@Bean
fun oidcCacheManager(cf: RedisConnectionFactory): CacheManager {
val redisCacheConfiguration = RedisCacheConfiguration.defaultCacheConfig()
Expand All @@ -25,9 +36,10 @@ class RedisCacheConfig {
),
)
.serializeValuesWith(
RedisSerializationContext.SerializationPair.fromSerializer(
GenericJackson2JsonRedisSerializer(),
),
RedisSerializationContext.SerializationPair
.fromSerializer(
GenericJackson2JsonRedisSerializer(objectMapper),
),
)
.entryTtl(Duration.ofDays(7L))
return RedisCacheManager.RedisCacheManagerBuilder.fromConnectionFactory(cf)
Expand Down

0 comments on commit 5360d30

Please sign in to comment.