Skip to content

Commit

Permalink
[feat] : redis 비밀번호 할당, 경매 상태 스케줄러 수정 (#164)
Browse files Browse the repository at this point in the history
* [feat] : Lettuce 연결 위한 redis 비밀번호 설정 추가

* [feat] : Redisson 연결 위한 redis 비밀번호 설정 추가

* [feat] : 경매 상태 관련 스케줄러 함수 수정
  • Loading branch information
hyun2371 authored May 3, 2024
1 parent 0747fba commit 1799fc4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
12 changes: 11 additions & 1 deletion api/src/main/java/dev/handsup/common/config/RedisConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.listener.PatternTopic;
Expand All @@ -26,9 +27,18 @@ public class RedisConfig {
@Value("${spring.data.redis.port}")
private int port;

@Value("${spring.data.redis.password:}")//
private String password;

@Bean
public RedisConnectionFactory redisConnectionFactory() {
return new LettuceConnectionFactory(host, port);
RedisStandaloneConfiguration config = new RedisStandaloneConfiguration();
config.setHostName(host);
config.setPort(port);
if (!password.isEmpty()) {
config.setPassword(password);
}
return new LettuceConnectionFactory(config);
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ public void updateAuctionStatusAfterEndDate() {
queryFactory
.update(auction)
.set(auction.status, AuctionStatus.CANCELED)
.where(auction.endDate.eq(LocalDate.now().minusDays(1)),
.where(auction.endDate.lt(LocalDate.now()),
auction.biddingCount.eq(0))
.execute();

queryFactory
.update(auction)
.set(auction.status, AuctionStatus.TRADING)
.where(auction.endDate.eq(LocalDate.now().minusDays(1)),
.where(auction.endDate.lt(LocalDate.now()),
auction.biddingCount.goe(1))
.execute();
}
Expand Down
13 changes: 9 additions & 4 deletions core/src/main/java/dev/handsup/common/config/RedissonConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@ public class RedissonConfig {
@Value("${spring.data.redis.port}")
private int port;

@Value("${spring.data.redis.password:}")
private String password;

@Bean
public RedissonClient redissonClient() {
RedissonClient redisson = null;
Config config = new Config();
config.useSingleServer().setAddress(REDISSON_HOST_PREFIX + host + ":" + port);
redisson = Redisson.create(config);
return redisson;
config.useSingleServer()
.setAddress(REDISSON_HOST_PREFIX + host + ":" + port);
if (!password.isEmpty()) {
config.useSingleServer().setPassword(password);
}
return Redisson.create(config);
}
}

0 comments on commit 1799fc4

Please sign in to comment.