Skip to content
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

fix : redis cache 관련 테스트 수정 #23

Merged
merged 3 commits into from
May 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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? {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

에러가 발생한건가용? joinPoint가 null이 반환될수있어서 그런거죠..?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

예압...!

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),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

objectmapper 추가 확인

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

늦어서 미안합니당ㅎ

),
)
.entryTtl(Duration.ofDays(7L))
return RedisCacheManager.RedisCacheManagerBuilder.fromConnectionFactory(cf)
Expand Down