22
33import com .alibaba .fastjson2 .JSON ;
44import com .alibaba .fastjson2 .JSONObject ;
5+ import com .hackyle .blog .admin .infrastructure .redis .CacheKey ;
56import com .hackyle .blog .admin .module .auth .model .dto .UserDetailsDto ;
67import com .hackyle .blog .admin .module .auth .service .LoginUserCacheService ;
7- import com .hackyle .blog .common .constant .CacheKeyConstants ;
88import lombok .extern .slf4j .Slf4j ;
99import org .springframework .beans .factory .annotation .Autowired ;
1010import org .springframework .beans .factory .annotation .Value ;
@@ -36,13 +36,13 @@ public class LoginUserCacheServiceImpl implements LoginUserCacheService {
3636
3737 @ Override
3838 public void putCache (UserDetailsDto userDetails ) {
39- String key = CacheKeyConstants . System .LOGIN_UID + userDetails .getUserId ();
39+ String key = CacheKey . Auth .LOGIN_UID + userDetails .getUserId ();
4040 redisTemplate .opsForValue ().set (key , userDetails , expireMinutes , TimeUnit .MINUTES );
4141 }
4242
4343 @ Override
4444 public void refreshCache (UserDetailsDto userDetailsDto ) {
45- String key = CacheKeyConstants . System .LOGIN_UID + userDetailsDto .getUserId ();
45+ String key = CacheKey . Auth .LOGIN_UID + userDetailsDto .getUserId ();
4646
4747 Long expire = redisTemplate .getExpire (key , TimeUnit .MINUTES );
4848 if (expire <= 20 ) { //登录态有效期小于5分钟,刷新缓存
@@ -53,7 +53,7 @@ public void refreshCache(UserDetailsDto userDetailsDto) {
5353
5454 @ Override
5555 public UserDetailsDto getCache (Long userId ) {
56- String key = CacheKeyConstants . System .LOGIN_UID + userId ;
56+ String key = CacheKey . Auth .LOGIN_UID + userId ;
5757
5858 Object object = redisTemplate .opsForValue ().get (key );
5959 if (object == null ) {
@@ -65,13 +65,13 @@ public UserDetailsDto getCache(Long userId) {
6565
6666 @ Override
6767 public boolean removeCache (Long userId ) {
68- String key = CacheKeyConstants . System .LOGIN_UID + userId ;
68+ String key = CacheKey . Auth .LOGIN_UID + userId ;
6969 return redisTemplate .delete (key );
7070 }
7171
7272 @ Override
7373 public List <UserDetailsDto > getAll () {
74- String keyPattern = CacheKeyConstants . System .LOGIN_UID + "*" ;
74+ String keyPattern = CacheKey . Auth .LOGIN_UID + "*" ;
7575 Set <String > keys = redisTemplate .keys (keyPattern );
7676
7777 List <UserDetailsDto > res = new ArrayList <>();
0 commit comments