From e6c21428536d301f583b677ced64e1f6e5cc5d5e Mon Sep 17 00:00:00 2001 From: Mithun James <1007084+drtechie@users.noreply.github.com> Date: Sat, 7 Jun 2025 17:36:21 +0530 Subject: [PATCH] fix: save minimal data to users_ key of Redis --- .../com/wipro/fhir/utils/JwtAuthenticationUtil.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/wipro/fhir/utils/JwtAuthenticationUtil.java b/src/main/java/com/wipro/fhir/utils/JwtAuthenticationUtil.java index 61cdc90..315fd14 100644 --- a/src/main/java/com/wipro/fhir/utils/JwtAuthenticationUtil.java +++ b/src/main/java/com/wipro/fhir/utils/JwtAuthenticationUtil.java @@ -111,15 +111,21 @@ private User fetchUserFromDB(String userId) { User user = userLoginRepo.getUserByUserID(Long.parseLong(userId)); if (user != null) { - // Cache the user in Redis for future requests (cache for 30 minutes) - redisTemplate.opsForValue().set(redisKey, user, 30, TimeUnit.MINUTES); + User userHash = new User(); + userHash.setUserID(user.getUserID()); + userHash.setUserName(user.getUserName()); + + // Cache the minimal user in Redis for future requests (cache for 30 minutes) + redisTemplate.opsForValue().set(redisKey, userHash, 30, TimeUnit.MINUTES); // Log that the user has been stored in Redis logger.info("User stored in Redis with key: " + redisKey); + + return user; } else { logger.warn("User not found for userId: " + userId); } - return user; + return null; } }