From cd4b165f9030ecc8b5dbf930f96adb1d3c122f52 Mon Sep 17 00:00:00 2001 From: Klaus Date: Tue, 17 Oct 2023 16:15:52 +0900 Subject: [PATCH 1/9] =?UTF-8?q?=EC=9D=B8=EA=B8=B0=20=EC=BD=98=ED=85=90?= =?UTF-8?q?=EC=B8=A0,=20=ED=81=90=EB=A0=88=EC=9D=B4=EC=85=98=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=EB=A1=9C=EC=A7=81=EC=97=90=20Cache=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vividnext/sodalive/configs/RedisConfig.kt | 35 +++++++++++++++++++ .../content/AudioContentRepository.kt | 11 ++++++ src/main/resources/application.yml | 2 ++ src/test/resources/application.yml | 2 ++ 4 files changed, 50 insertions(+) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/configs/RedisConfig.kt b/src/main/kotlin/kr/co/vividnext/sodalive/configs/RedisConfig.kt index 22480ee..0ec3965 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/configs/RedisConfig.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/configs/RedisConfig.kt @@ -1,14 +1,22 @@ package kr.co.vividnext.sodalive.configs import org.springframework.beans.factory.annotation.Value +import org.springframework.cache.annotation.EnableCaching import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration +import org.springframework.data.redis.cache.RedisCacheConfiguration +import org.springframework.data.redis.cache.RedisCacheManager import org.springframework.data.redis.connection.RedisConnectionFactory import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory import org.springframework.data.redis.core.RedisTemplate import org.springframework.data.redis.repository.configuration.EnableRedisRepositories +import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer +import org.springframework.data.redis.serializer.RedisSerializationContext +import org.springframework.data.redis.serializer.StringRedisSerializer +import java.time.Duration @Configuration +@EnableCaching @EnableRedisRepositories class RedisConfig( @Value("\${spring.redis.host}") @@ -27,4 +35,31 @@ class RedisConfig( redisTemplate.setConnectionFactory(redisConnectionFactory()) return redisTemplate } + + @Bean + fun cacheManager(connectionFactory: RedisConnectionFactory): RedisCacheManager { + val defaultConfig = RedisCacheConfiguration.defaultCacheConfig() + .entryTtl(Duration.ofMinutes(10)) // Default TTL + .serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(StringRedisSerializer())) + .serializeValuesWith( + RedisSerializationContext.SerializationPair.fromSerializer( + GenericJackson2JsonRedisSerializer() + ) + ) + + val weekLivedCacheConfig = RedisCacheConfiguration.defaultCacheConfig() + .entryTtl(Duration.ofDays(7)) + .serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(StringRedisSerializer())) + .serializeValuesWith( + RedisSerializationContext.SerializationPair.fromSerializer( + GenericJackson2JsonRedisSerializer() + ) + ) + + return RedisCacheManager.RedisCacheManagerBuilder + .fromConnectionFactory(connectionFactory) + .cacheDefaults(defaultConfig) + .withCacheConfiguration("weekLivedCache", weekLivedCacheConfig) + .build() + } } diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentRepository.kt b/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentRepository.kt index 038f732..08ef606 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentRepository.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentRepository.kt @@ -18,6 +18,7 @@ import kr.co.vividnext.sodalive.content.order.QOrder.order import kr.co.vividnext.sodalive.content.theme.QAudioContentTheme.audioContentTheme import kr.co.vividnext.sodalive.event.QEvent.event import kr.co.vividnext.sodalive.member.QMember.member +import org.springframework.cache.annotation.Cacheable import org.springframework.data.jpa.repository.JpaRepository import org.springframework.stereotype.Repository import java.time.LocalDateTime @@ -387,6 +388,11 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) .fetch() } + @Cacheable( + value = ["getAudioContentCurations"], + key = "#isAdult", + cacheManager = "cacheManager" + ) override fun getAudioContentCurations(isAdult: Boolean): List { var where = audioContentCuration.isActive.isTrue @@ -438,6 +444,11 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) .fetch() } + @Cacheable( + value = ["weekLivedCache"], + key = "#startDate" + '_' + "#isAdult" + '_' + "#offset" + '_' + "#limit", + cacheManager = "cacheManager" + ) override fun getAudioContentRanking( cloudfrontHost: String, isAdult: Boolean, diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 4dd8bb8..3be6e79 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -73,6 +73,8 @@ spring: multipart: max-file-size: 1024MB max-request-size: 1024MB + cache: + type: redis --- spring: config: diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml index c831d44..6639ad7 100644 --- a/src/test/resources/application.yml +++ b/src/test/resources/application.yml @@ -47,3 +47,5 @@ spring: hibernate: show_sql: true format_sql: true + cache: + type: redis From 0f6c3075bc2d1d1c16e255c0e23e86cb4f8d9733 Mon Sep 17 00:00:00 2001 From: Klaus Date: Tue, 17 Oct 2023 16:33:21 +0900 Subject: [PATCH 2/9] =?UTF-8?q?=EC=9D=B8=EA=B8=B0=20=EC=BD=98=ED=85=90?= =?UTF-8?q?=EC=B8=A0=20Cache=20=EB=A1=9C=EC=A7=81=20-=20key=20=EA=B0=92?= =?UTF-8?q?=EC=97=90=EC=84=9C=20LocalDateTime=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kr/co/vividnext/sodalive/content/AudioContentRepository.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentRepository.kt b/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentRepository.kt index 08ef606..d1ab467 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentRepository.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentRepository.kt @@ -446,7 +446,7 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) @Cacheable( value = ["weekLivedCache"], - key = "#startDate" + '_' + "#isAdult" + '_' + "#offset" + '_' + "#limit", + key = "#isAdult" + '_' + "#offset" + '_' + "#limit", cacheManager = "cacheManager" ) override fun getAudioContentRanking( From bcdd161205d585af1f4da84fd7e85f7a2c004e55 Mon Sep 17 00:00:00 2001 From: Klaus Date: Tue, 17 Oct 2023 16:59:16 +0900 Subject: [PATCH 3/9] =?UTF-8?q?LocalDateTime=20serialize=20=EB=8F=84?= =?UTF-8?q?=EC=A4=91=20=EB=B0=9C=EC=83=9D=ED=95=98=EB=8A=94=20=EC=97=90?= =?UTF-8?q?=EB=9F=AC=EB=A5=BC=20=EC=B2=98=EB=A6=AC=ED=95=98=EA=B8=B0=20?= =?UTF-8?q?=EC=9C=84=ED=95=B4=20JacksonConfig=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../co/vividnext/sodalive/configs/JacksonConfig.kt | 14 ++++++++++++++ .../sodalive/content/AudioContentRepository.kt | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 src/main/kotlin/kr/co/vividnext/sodalive/configs/JacksonConfig.kt diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/configs/JacksonConfig.kt b/src/main/kotlin/kr/co/vividnext/sodalive/configs/JacksonConfig.kt new file mode 100644 index 0000000..4330c89 --- /dev/null +++ b/src/main/kotlin/kr/co/vividnext/sodalive/configs/JacksonConfig.kt @@ -0,0 +1,14 @@ +package kr.co.vividnext.sodalive.configs + +import com.fasterxml.jackson.databind.ObjectMapper +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration + +@Configuration +class JacksonConfig { + @Bean + fun objectMapper(): ObjectMapper { + return ObjectMapper().registerModule(JavaTimeModule()) + } +} diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentRepository.kt b/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentRepository.kt index d1ab467..08ef606 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentRepository.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentRepository.kt @@ -446,7 +446,7 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) @Cacheable( value = ["weekLivedCache"], - key = "#isAdult" + '_' + "#offset" + '_' + "#limit", + key = "#startDate" + '_' + "#isAdult" + '_' + "#offset" + '_' + "#limit", cacheManager = "cacheManager" ) override fun getAudioContentRanking( From 99d7510c3207a68a8ac297656a936b30e90db914 Mon Sep 17 00:00:00 2001 From: Klaus Date: Tue, 17 Oct 2023 17:15:55 +0900 Subject: [PATCH 4/9] =?UTF-8?q?LocalDateTime=20serialize=20=EC=97=90?= =?UTF-8?q?=EB=9F=AC=EB=A5=BC=20=EC=B2=98=EB=A6=AC=20-=20JacksonConfig=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0,=20@JsonSerialize(using=20=3D=20LocalDateTim?= =?UTF-8?q?eSerializer::class)=20=20=20=20=20=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20=20=20=20@JsonDeserialize(using=20=3D=20LocalDateTi?= =?UTF-8?q?meDeserializer::class)=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kr/co/vividnext/sodalive/common/BaseEntity.kt | 9 +++++++++ .../co/vividnext/sodalive/configs/JacksonConfig.kt | 14 -------------- 2 files changed, 9 insertions(+), 14 deletions(-) delete mode 100644 src/main/kotlin/kr/co/vividnext/sodalive/configs/JacksonConfig.kt diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/common/BaseEntity.kt b/src/main/kotlin/kr/co/vividnext/sodalive/common/BaseEntity.kt index bf2b11d..622dd1b 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/common/BaseEntity.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/common/BaseEntity.kt @@ -1,5 +1,9 @@ package kr.co.vividnext.sodalive.common +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer +import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer import java.time.LocalDateTime import javax.persistence.GeneratedValue import javax.persistence.GenerationType @@ -14,7 +18,12 @@ abstract class BaseEntity { @GeneratedValue(strategy = GenerationType.IDENTITY) var id: Long? = null + @JsonSerialize(using = LocalDateTimeSerializer::class) + @JsonDeserialize(using = LocalDateTimeDeserializer::class) var createdAt: LocalDateTime? = null + + @JsonSerialize(using = LocalDateTimeSerializer::class) + @JsonDeserialize(using = LocalDateTimeDeserializer::class) var updatedAt: LocalDateTime? = null @PrePersist diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/configs/JacksonConfig.kt b/src/main/kotlin/kr/co/vividnext/sodalive/configs/JacksonConfig.kt deleted file mode 100644 index 4330c89..0000000 --- a/src/main/kotlin/kr/co/vividnext/sodalive/configs/JacksonConfig.kt +++ /dev/null @@ -1,14 +0,0 @@ -package kr.co.vividnext.sodalive.configs - -import com.fasterxml.jackson.databind.ObjectMapper -import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule -import org.springframework.context.annotation.Bean -import org.springframework.context.annotation.Configuration - -@Configuration -class JacksonConfig { - @Bean - fun objectMapper(): ObjectMapper { - return ObjectMapper().registerModule(JavaTimeModule()) - } -} From 3537f22197f6033ee5b174e5a9f56ab9322eef29 Mon Sep 17 00:00:00 2001 From: Klaus Date: Tue, 17 Oct 2023 17:28:30 +0900 Subject: [PATCH 5/9] =?UTF-8?q?com.fasterxml.jackson.databind.exc.InvalidD?= =?UTF-8?q?efinitionException=20=EC=97=90=EB=9F=AC=EB=A5=BC=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC=ED=95=98=EA=B8=B0=20=EC=9C=84=ED=95=B4=20-=20theme?= =?UTF-8?q?=EC=9D=98=20fetchType=EC=9D=84=20EAGER=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kr/co/vividnext/sodalive/content/AudioContent.kt | 2 +- .../sodalive/content/main/curation/AudioContentCuration.kt | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContent.kt b/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContent.kt index 116d8b4..2a622f0 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContent.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContent.kt @@ -42,7 +42,7 @@ data class AudioContent( var content: String? = null var coverImage: String? = null - @OneToOne(fetch = FetchType.LAZY) + @OneToOne(fetch = FetchType.EAGER) @JoinColumn(name = "theme_id", nullable = false) var theme: AudioContentTheme? = null diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/content/main/curation/AudioContentCuration.kt b/src/main/kotlin/kr/co/vividnext/sodalive/content/main/curation/AudioContentCuration.kt index 83ec820..d5955cf 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/content/main/curation/AudioContentCuration.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/content/main/curation/AudioContentCuration.kt @@ -1,10 +1,8 @@ package kr.co.vividnext.sodalive.content.main.curation import kr.co.vividnext.sodalive.common.BaseEntity -import kr.co.vividnext.sodalive.content.AudioContent import javax.persistence.Column import javax.persistence.Entity -import javax.persistence.OneToMany import javax.persistence.Table @Entity @@ -20,7 +18,4 @@ data class AudioContentCuration( var isActive: Boolean = true, @Column(nullable = false) var orders: Int = 1 -) : BaseEntity() { - @OneToMany(mappedBy = "curation") - val audioContents: MutableList = mutableListOf() -} +) : BaseEntity() From 1fcb0ec5fd54b0a98ca55cec11eb4ece1b1089ac Mon Sep 17 00:00:00 2001 From: Klaus Date: Tue, 17 Oct 2023 17:39:22 +0900 Subject: [PATCH 6/9] =?UTF-8?q?org.springframework.expression.spel.SpelPar?= =?UTF-8?q?seException=20=EB=AC=B8=EC=A0=9C=EB=A5=BC=20=EC=A0=9C=EA=B1=B0?= =?UTF-8?q?=ED=95=98=EA=B8=B0=20=EC=9C=84=ED=95=B4=20key=EC=84=A4=EC=A0=95?= =?UTF-8?q?=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kr/co/vividnext/sodalive/content/AudioContentRepository.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentRepository.kt b/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentRepository.kt index 08ef606..bbed90d 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentRepository.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentRepository.kt @@ -390,7 +390,6 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) @Cacheable( value = ["getAudioContentCurations"], - key = "#isAdult", cacheManager = "cacheManager" ) override fun getAudioContentCurations(isAdult: Boolean): List { @@ -446,7 +445,6 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) @Cacheable( value = ["weekLivedCache"], - key = "#startDate" + '_' + "#isAdult" + '_' + "#offset" + '_' + "#limit", cacheManager = "cacheManager" ) override fun getAudioContentRanking( From e5c85287bbc0b5e2188e28b19c79215fdeef8b3e Mon Sep 17 00:00:00 2001 From: Klaus Date: Tue, 17 Oct 2023 17:58:24 +0900 Subject: [PATCH 7/9] =?UTF-8?q?=EC=BA=90=EC=8B=9C=20=EC=A0=81=EC=9A=A9=20-?= =?UTF-8?q?=20=EC=B6=94=EC=B2=9C=EB=9D=BC=EC=9D=B4=EB=B8=8C,=20=EC=9D=B4?= =?UTF-8?q?=EB=B2=A4=ED=8A=B8=20=EB=A6=AC=EC=8A=A4=ED=8A=B8,=202=EC=A3=BC?= =?UTF-8?q?=20=EC=9D=B4=EB=82=B4=20=EC=BD=98=ED=85=90=EC=B8=A0=20=EC=97=85?= =?UTF-8?q?=EB=A1=9C=EB=93=9C=20=ED=95=9C=20=ED=81=AC=EB=A6=AC=EC=97=90?= =?UTF-8?q?=EC=9D=B4=ED=84=B0,=20=EC=BD=98=ED=85=90=EC=B8=A0=20=EC=83=81?= =?UTF-8?q?=EB=8B=A8=20=EB=B0=B0=EB=84=88,?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kr/co/vividnext/sodalive/configs/RedisConfig.kt | 4 ++-- .../vividnext/sodalive/content/AudioContentRepository.kt | 8 ++++++++ .../kotlin/kr/co/vividnext/sodalive/event/EventService.kt | 5 +++++ .../sodalive/live/recommend/LiveRecommendRepository.kt | 5 +++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/configs/RedisConfig.kt b/src/main/kotlin/kr/co/vividnext/sodalive/configs/RedisConfig.kt index 0ec3965..f309011 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/configs/RedisConfig.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/configs/RedisConfig.kt @@ -39,7 +39,7 @@ class RedisConfig( @Bean fun cacheManager(connectionFactory: RedisConnectionFactory): RedisCacheManager { val defaultConfig = RedisCacheConfiguration.defaultCacheConfig() - .entryTtl(Duration.ofMinutes(10)) // Default TTL + .entryTtl(Duration.ofHours(1)) // Default TTL .serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(StringRedisSerializer())) .serializeValuesWith( RedisSerializationContext.SerializationPair.fromSerializer( @@ -48,7 +48,7 @@ class RedisConfig( ) val weekLivedCacheConfig = RedisCacheConfiguration.defaultCacheConfig() - .entryTtl(Duration.ofDays(7)) + .entryTtl(Duration.ofDays(3)) .serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(StringRedisSerializer())) .serializeValuesWith( RedisSerializationContext.SerializationPair.fromSerializer( diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentRepository.kt b/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentRepository.kt index bbed90d..862f272 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentRepository.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentRepository.kt @@ -337,6 +337,10 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) .fetch() } + @Cacheable( + value = ["getNewContentUploadCreatorList"], + cacheManager = "cacheManager" + ) override fun getNewContentUploadCreatorList( cloudfrontHost: String, isAdult: Boolean @@ -372,6 +376,10 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) .toList() } + @Cacheable( + value = ["getAudioContentMainBannerList"], + cacheManager = "cacheManager" + ) override fun getAudioContentMainBannerList(isAdult: Boolean): List { var where = audioContentBanner.isActive.isTrue diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/event/EventService.kt b/src/main/kotlin/kr/co/vividnext/sodalive/event/EventService.kt index e6ddd74..2237d7b 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/event/EventService.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/event/EventService.kt @@ -5,6 +5,7 @@ import kr.co.vividnext.sodalive.aws.s3.S3Uploader import kr.co.vividnext.sodalive.common.SodaException import kr.co.vividnext.sodalive.utils.generateFileName import org.springframework.beans.factory.annotation.Value +import org.springframework.cache.annotation.Cacheable import org.springframework.data.repository.findByIdOrNull import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional @@ -20,6 +21,10 @@ class EventService( @Value("\${cloud.aws.cloud-front.host}") private val cloudFrontHost: String ) { + @Cacheable( + value = ["getEventList"], + cacheManager = "cacheManager" + ) fun getEventList(): GetEventResponse { val eventList = repository.getEventList() .asSequence() diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/live/recommend/LiveRecommendRepository.kt b/src/main/kotlin/kr/co/vividnext/sodalive/live/recommend/LiveRecommendRepository.kt index e6ece32..b65eecb 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/live/recommend/LiveRecommendRepository.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/live/recommend/LiveRecommendRepository.kt @@ -9,6 +9,7 @@ import kr.co.vividnext.sodalive.member.MemberRole import kr.co.vividnext.sodalive.member.QMember.member import kr.co.vividnext.sodalive.member.following.QCreatorFollowing.creatorFollowing import org.springframework.beans.factory.annotation.Value +import org.springframework.cache.annotation.Cacheable import org.springframework.stereotype.Repository import java.time.LocalDateTime @@ -19,6 +20,10 @@ class LiveRecommendRepository( @Value("\${cloud.aws.cloud-front.host}") private val cloudFrontHost: String ) { + @Cacheable( + value = ["getRecommendLive"], + cacheManager = "cacheManager" + ) fun getRecommendLive( memberId: Long, isBlocked: (Long) -> Boolean, From cda2f1ec3684464521c7f5398e3a4d6d4d43d75b Mon Sep 17 00:00:00 2001 From: Klaus Date: Tue, 17 Oct 2023 18:11:56 +0900 Subject: [PATCH 8/9] =?UTF-8?q?=EA=B8=B0=EB=B3=B8=20=EC=83=9D=EC=84=B1?= =?UTF-8?q?=EC=9E=90=20=EC=97=86=EB=8A=94=20data=20class=EC=97=90=20@JsonP?= =?UTF-8?q?roperty=EB=A5=BC=20=EC=B6=94=EA=B0=80=ED=95=98=EC=97=AC=20Jacks?= =?UTF-8?q?on=EC=97=90=EC=84=9C=20=EC=A7=81=EB=A0=AC=ED=99=94=20=ED=95=A0?= =?UTF-8?q?=20=EC=88=98=20=EC=9E=88=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../content/main/GetAudioContentRanking.kt | 17 +++++++++-------- .../main/GetNewContentUploadCreator.kt | 7 ++++--- .../sodalive/event/GetEventResponse.kt | 19 ++++++++++--------- .../recommend/GetRecommendLiveResponse.kt | 6 ++++-- 4 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/content/main/GetAudioContentRanking.kt b/src/main/kotlin/kr/co/vividnext/sodalive/content/main/GetAudioContentRanking.kt index 1d9dbdf..3209e71 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/content/main/GetAudioContentRanking.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/content/main/GetAudioContentRanking.kt @@ -1,5 +1,6 @@ package kr.co.vividnext.sodalive.content.main +import com.fasterxml.jackson.annotation.JsonProperty import com.querydsl.core.annotations.QueryProjection data class GetAudioContentRanking( @@ -9,12 +10,12 @@ data class GetAudioContentRanking( ) data class GetAudioContentRankingItem @QueryProjection constructor( - val contentId: Long, - val title: String, - val coverImageUrl: String, - val themeStr: String, - val price: Int, - val duration: String, - val creatorId: Long, - val creatorNickname: String + @JsonProperty("contentId") val contentId: Long, + @JsonProperty("title") val title: String, + @JsonProperty("coverImageUrl") val coverImageUrl: String, + @JsonProperty("themeStr") val themeStr: String, + @JsonProperty("price") val price: Int, + @JsonProperty("duration") val duration: String, + @JsonProperty("creatorId") val creatorId: Long, + @JsonProperty("creatorNickname") val creatorNickname: String ) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/content/main/GetNewContentUploadCreator.kt b/src/main/kotlin/kr/co/vividnext/sodalive/content/main/GetNewContentUploadCreator.kt index 55a50a7..a53d1d3 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/content/main/GetNewContentUploadCreator.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/content/main/GetNewContentUploadCreator.kt @@ -1,9 +1,10 @@ package kr.co.vividnext.sodalive.content.main +import com.fasterxml.jackson.annotation.JsonProperty import com.querydsl.core.annotations.QueryProjection data class GetNewContentUploadCreator @QueryProjection constructor( - val creatorId: Long, - val creatorNickname: String, - val creatorProfileImageUrl: String + @JsonProperty("creatorId") val creatorId: Long, + @JsonProperty("creatorNickname") val creatorNickname: String, + @JsonProperty("creatorProfileImageUrl") val creatorProfileImageUrl: String ) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/event/GetEventResponse.kt b/src/main/kotlin/kr/co/vividnext/sodalive/event/GetEventResponse.kt index 5a0b6ee..79d2b50 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/event/GetEventResponse.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/event/GetEventResponse.kt @@ -1,18 +1,19 @@ package kr.co.vividnext.sodalive.event +import com.fasterxml.jackson.annotation.JsonProperty import com.querydsl.core.annotations.QueryProjection data class GetEventResponse( - val totalCount: Int, - val eventList: List + @JsonProperty("totalCount") val totalCount: Int, + @JsonProperty("eventList") val eventList: List ) data class EventItem @QueryProjection constructor( - val id: Long, - val title: String? = null, - var thumbnailImageUrl: String, - var detailImageUrl: String? = null, - var popupImageUrl: String? = null, - val link: String? = null, - val isPopup: Boolean + @JsonProperty("id") val id: Long, + @JsonProperty("title") val title: String? = null, + @JsonProperty("thumbnailImageUrl") var thumbnailImageUrl: String, + @JsonProperty("detailImageUrl") var detailImageUrl: String? = null, + @JsonProperty("popupImageUrl") var popupImageUrl: String? = null, + @JsonProperty("link") val link: String? = null, + @JsonProperty("isPopup") val isPopup: Boolean ) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/live/recommend/GetRecommendLiveResponse.kt b/src/main/kotlin/kr/co/vividnext/sodalive/live/recommend/GetRecommendLiveResponse.kt index 97f21fe..2b7e2f8 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/live/recommend/GetRecommendLiveResponse.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/live/recommend/GetRecommendLiveResponse.kt @@ -1,6 +1,8 @@ package kr.co.vividnext.sodalive.live.recommend +import com.fasterxml.jackson.annotation.JsonProperty + data class GetRecommendLiveResponse( - val imageUrl: String, - val creatorId: Long + @JsonProperty("imageUrl") val imageUrl: String, + @JsonProperty("creatorId") val creatorId: Long ) From 1be91d0de4d00ab3415c1f4aea72885a2d59da02 Mon Sep 17 00:00:00 2001 From: Klaus Date: Tue, 17 Oct 2023 18:25:45 +0900 Subject: [PATCH 9/9] =?UTF-8?q?EventItem=20-=20Json=20=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=84=B0=EC=97=90=EB=8A=94=20=EC=9E=88=EC=A7=80=EB=A7=8C=20DTO?= =?UTF-8?q?=EC=97=90=EB=8A=94=20Key=EA=B0=92=EC=9D=B4=20=EC=97=86=EB=8A=94?= =?UTF-8?q?=20=EA=B2=BD=EC=9A=B0=20=EB=B0=9C=EC=83=9D=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/kr/co/vividnext/sodalive/event/GetEventResponse.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/event/GetEventResponse.kt b/src/main/kotlin/kr/co/vividnext/sodalive/event/GetEventResponse.kt index 79d2b50..4e3b711 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/event/GetEventResponse.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/event/GetEventResponse.kt @@ -1,5 +1,6 @@ package kr.co.vividnext.sodalive.event +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty import com.querydsl.core.annotations.QueryProjection @@ -8,6 +9,7 @@ data class GetEventResponse( @JsonProperty("eventList") val eventList: List ) +@JsonIgnoreProperties(ignoreUnknown = true) data class EventItem @QueryProjection constructor( @JsonProperty("id") val id: Long, @JsonProperty("title") val title: String? = null,