diff --git a/backend/src/main/java/com/dragonguard/backend/config/redis/RedisConfig.java b/backend/src/main/java/com/dragonguard/backend/config/redis/RedisConfig.java index 5987024d..1290e988 100644 --- a/backend/src/main/java/com/dragonguard/backend/config/redis/RedisConfig.java +++ b/backend/src/main/java/com/dragonguard/backend/config/redis/RedisConfig.java @@ -19,8 +19,6 @@ import org.springframework.data.redis.serializer.RedisSerializationContext; import org.springframework.data.redis.serializer.StringRedisSerializer; -import java.time.Duration; - /** * @author 김승진 * @description Redis 캐쉬를 사용하기 위한 설정을 등록하는 클래스 @@ -30,7 +28,6 @@ @EnableRedisRepositories @RequiredArgsConstructor public class RedisConfig { - private static final Long TIME_TO_LIVE = 1L; private static final String REDISSON_HOST_PREFIX = "redis://"; private static final String URL_DELIMITER = ":"; private final RedisProperties redisProperties; @@ -70,8 +67,7 @@ public CacheManager cacheManager(final RedisConnectionFactory cf) { new StringRedisSerializer())) .serializeValuesWith( RedisSerializationContext.SerializationPair.fromSerializer( - new GenericJackson2JsonRedisSerializer())) - .entryTtl(Duration.ofHours(TIME_TO_LIVE)); + new GenericJackson2JsonRedisSerializer())); return RedisCacheManager.RedisCacheManagerBuilder.fromConnectionFactory(cf) .cacheDefaults(redisCacheConfiguration) diff --git a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/service/BlockchainService.java b/backend/src/main/java/com/dragonguard/backend/domain/blockchain/service/BlockchainService.java index 5e33f991..0efb4c23 100644 --- a/backend/src/main/java/com/dragonguard/backend/domain/blockchain/service/BlockchainService.java +++ b/backend/src/main/java/com/dragonguard/backend/domain/blockchain/service/BlockchainService.java @@ -10,7 +10,6 @@ import com.dragonguard.backend.global.annotation.TransactionService; import com.dragonguard.backend.global.exception.EntityNotFoundException; import com.dragonguard.backend.global.template.service.EntityLoader; -import com.dragonguard.backend.utils.RedisRankingUtils; import lombok.RequiredArgsConstructor; @@ -32,7 +31,6 @@ public class BlockchainService implements EntityLoader { private final SmartContractService smartContractService; private final BlockchainMapper blockchainMapper; private final AuthService authService; - private final RedisRankingUtils redisRankingUtils; public void setTransaction( final Member member, final long contribution, final ContributeType contributeType) { @@ -55,7 +53,6 @@ public void setTransaction( if (balance.equals(expected)) { blockchain.addHistory(expected, transactionHash); - redisRankingUtils.addUserScore(member); } } diff --git a/backend/src/main/java/com/dragonguard/backend/domain/search/service/SearchServiceImpl.java b/backend/src/main/java/com/dragonguard/backend/domain/search/service/SearchServiceImpl.java index 5eca7b3c..d67ff323 100644 --- a/backend/src/main/java/com/dragonguard/backend/domain/search/service/SearchServiceImpl.java +++ b/backend/src/main/java/com/dragonguard/backend/domain/search/service/SearchServiceImpl.java @@ -13,8 +13,6 @@ import lombok.RequiredArgsConstructor; -import org.springframework.cache.annotation.Cacheable; - import java.util.HashSet; import java.util.List; import java.util.Objects; @@ -81,12 +79,10 @@ public Search loadEntity(final Long id) { return searchRepository.findById(id).orElseThrow(EntityNotFoundException::new); } - @Cacheable(value = "userResults", key = "{#searchRequest}", cacheManager = "cacheManager") public SearchUserResponse requestUserToGithub(final SearchRequest searchRequest) { return githubUserClient.requestToGithub(searchRequest); } - @Cacheable(value = "repoResults", key = "{#searchRequest}", cacheManager = "cacheManager") public SearchRepoResponse requestRepoToGithub(final SearchRequest searchRequest) { return githubRepoClient.requestToGithub(searchRequest); } diff --git a/backend/src/main/java/com/dragonguard/backend/global/template/service/ContributionService.java b/backend/src/main/java/com/dragonguard/backend/global/template/service/ContributionService.java index e401296e..344c406d 100644 --- a/backend/src/main/java/com/dragonguard/backend/global/template/service/ContributionService.java +++ b/backend/src/main/java/com/dragonguard/backend/global/template/service/ContributionService.java @@ -11,6 +11,7 @@ import com.dragonguard.backend.global.template.kafka.EventProducer; import com.dragonguard.backend.global.template.mapper.ContributionMapper; import com.dragonguard.backend.global.template.repository.ContributionRepository; +import com.dragonguard.backend.utils.RedisRankingUtils; import lombok.RequiredArgsConstructor; @@ -26,6 +27,7 @@ public abstract class ContributionService private final ContributionMapper commitMapper; private final EventProducer blockchainEventProducer; private final BlockchainService blockchainService; + private final RedisRankingUtils redisRankingUtils; @DistributedLock(name = "#member.getGithubId().concat(#contributeType.name())") public void saveContribution( @@ -37,9 +39,11 @@ public void saveContribution( if (existsByMemberAndYear(member, year)) { updateAndSendTransaction(member, contributionNum, year, blockchain, contributeType); + redisRankingUtils.addUserScore(member); return; } contributionRepository.save(commitMapper.toEntity(member, contributionNum, year)); + redisRankingUtils.addUserScore(member); sendTransaction(member, contributionNum.longValue(), blockchain, contributeType); }