Add Redis Configuration

This commit is contained in:
kimyonghwa
2019-08-06 00:47:00 +09:00
parent bdd09eeaa9
commit e729ff1504
13 changed files with 160 additions and 5 deletions

View File

@@ -1,8 +1,10 @@
package com.rest.api.service.security;
import com.rest.api.advice.exception.CUserNotFoundException;
import com.rest.api.common.CacheKey;
import com.rest.api.repo.UserJpaRepo;
import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.stereotype.Service;
@@ -13,6 +15,7 @@ public class CustomUserDetailService implements UserDetailsService {
private final UserJpaRepo userJpaRepo;
@Cacheable(value = CacheKey.USER, key = "#userPk", unless = "#result == null")
public UserDetails loadUserByUsername(String userPk) {
return userJpaRepo.findById(Long.valueOf(userPk)).orElseThrow(CUserNotFoundException::new);
}