Skip to content

Commit

Permalink
feat: temp deploy version
Browse files Browse the repository at this point in the history
  • Loading branch information
ohksj77 committed Oct 3, 2024
1 parent bfc3869 commit f647c8d
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 캐쉬를 사용하기 위한 설정을 등록하는 클래스
Expand All @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -32,7 +31,6 @@ public class BlockchainService implements EntityLoader<Blockchain, Long> {
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) {
Expand All @@ -55,7 +53,6 @@ public void setTransaction(

if (balance.equals(expected)) {
blockchain.addHistory(expected, transactionHash);
redisRankingUtils.addUserScore(member);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -26,6 +27,7 @@ public abstract class ContributionService<T extends Contribution, ID>
private final ContributionMapper<T> commitMapper;
private final EventProducer<BlockchainEvent> blockchainEventProducer;
private final BlockchainService blockchainService;
private final RedisRankingUtils redisRankingUtils;

@DistributedLock(name = "#member.getGithubId().concat(#contributeType.name())")
public void saveContribution(
Expand All @@ -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);
}

Expand Down

0 comments on commit f647c8d

Please sign in to comment.