forked from baron/baron-sso
only JWT 발급
This commit is contained in:
@@ -18,7 +18,7 @@ type RedisService struct {
|
||||
func NewRedisService() (*RedisService, error) {
|
||||
redisAddr := os.Getenv("REDIS_ADDR")
|
||||
if redisAddr == "" {
|
||||
redisAddr = "localhost:6379" // Fallback for local dev without Docker
|
||||
redisAddr = "localhost:6389" // Fallback for local dev without Docker
|
||||
}
|
||||
|
||||
rdb := redis.NewClient(&redis.Options{
|
||||
@@ -60,3 +60,22 @@ func (s *RedisService) DeleteVerificationCode(phone string) error {
|
||||
key := "sms_verify:" + phone
|
||||
return s.Client.Del(ctx, key).Err()
|
||||
}
|
||||
|
||||
// Set stores a key-value pair with expiration
|
||||
func (s *RedisService) Set(key string, value string, expiration time.Duration) error {
|
||||
return s.Client.Set(ctx, key, value, expiration).Err()
|
||||
}
|
||||
|
||||
// Get retrieves a value by key
|
||||
func (s *RedisService) Get(key string) (string, error) {
|
||||
val, err := s.Client.Get(ctx, key).Result()
|
||||
if err == redis.Nil {
|
||||
return "", nil
|
||||
}
|
||||
return val, err
|
||||
}
|
||||
|
||||
// Delete removes a key
|
||||
func (s *RedisService) Delete(key string) error {
|
||||
return s.Client.Del(ctx, key).Err()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user