Skip to content

Commit

Permalink
fix: 레디스 request 토큰 조회 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
KarmaPol committed Feb 12, 2024
1 parent 5e5a4e6 commit 3f34d3c
Showing 1 changed file with 21 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
package com.mm.coreinfraredis.repository;

import java.util.Optional;
import java.util.concurrent.TimeUnit;

import lombok.RequiredArgsConstructor;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Repository;

import lombok.RequiredArgsConstructor;
import java.util.Optional;
import java.util.concurrent.TimeUnit;

@Repository
@RequiredArgsConstructor
public class RedisRefreshTokenRepository {
private final RedisTemplate redisTemplate;
private static final long REFRESH_TOKEN_EXPIRE_LONG = 259200L;
private final RedisTemplate redisTemplate;
private static final long REFRESH_TOKEN_EXPIRE_LONG = 259200L;

public void save(String refreshToken, Long memberId) {
ValueOperations<String, Long> valueOperations = redisTemplate.opsForValue();
valueOperations.set(refreshToken, memberId);
redisTemplate.expire(refreshToken, REFRESH_TOKEN_EXPIRE_LONG, TimeUnit.SECONDS);
}
public void save(String refreshToken, Long memberId) {
ValueOperations<String, Long> valueOperations = redisTemplate.opsForValue();
valueOperations.set(refreshToken, memberId);
redisTemplate.expire(refreshToken, REFRESH_TOKEN_EXPIRE_LONG, TimeUnit.SECONDS);
}

public void delete(String refreshToken) {
redisTemplate.delete(refreshToken);
}
public void delete(String refreshToken) {
redisTemplate.delete(refreshToken);
}

public Optional<Long> findByRefreshToken(String refreshToken) {
ValueOperations<String, Integer> valueOperations = redisTemplate.opsForValue();
Long memberId = valueOperations.get(refreshToken).longValue();
return Optional.ofNullable(memberId);
}
public Optional<Long> findByRefreshToken(String refreshToken) {
ValueOperations<String, Integer> valueOperations = redisTemplate.opsForValue();
Integer memberId = valueOperations.get(refreshToken);
if (memberId == null) {
return Optional.ofNullable(null);
}
return Optional.ofNullable(memberId.longValue());
}
}

0 comments on commit 3f34d3c

Please sign in to comment.