Skip to content

Commit

Permalink
Fixed issue in add / read string to RedisCache.
Browse files Browse the repository at this point in the history
  • Loading branch information
karthik-tarento committed Apr 17, 2023
1 parent b0c758d commit 4b769bd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
14 changes: 14 additions & 0 deletions src/main/java/org/sunbird/cache/RedisCacheMgr.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,20 @@ public void putCache(String key, Object object) {
}
}

public void putStringInCache(String key, String value) {
try {
int ttl = cache_ttl;
if (!StringUtils.isEmpty(cbExtServerProperties.getRedisTimeout())) {
ttl = Integer.parseInt(cbExtServerProperties.getRedisTimeout());
}
getJedis().set(Constants.REDIS_COMMON_KEY + key, value);
getJedis().expire(Constants.REDIS_COMMON_KEY + key, ttl);
logger.info("Cache_key_value " + Constants.REDIS_COMMON_KEY + key + " is saved in redis");
} catch (Exception e) {
logger.error(e);
}
}

public boolean deleteKeyByName(String key) {
try {
getJedis().del(Constants.REDIS_COMMON_KEY + key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ public SBApiResponse orgProfileRead(String orgId) throws Exception {
}

public SBApiResponse userBasicInfo(String userId) {
SBApiResponse response = ProjectUtil.createDefaultResponse(Constants.API_USER_BASIC_INFO);
SBApiResponse response = ProjectUtil.createDefaultResponse(Constants.API_USER_BASIC_INFO);
try {
Map<String, Object> userData = userUtilityService.getUsersReadData(userId, StringUtils.EMPTY,
StringUtils.EMPTY);
Expand Down Expand Up @@ -814,7 +814,7 @@ public String getCustodianOrgId() {
Map<String, Object> data = existingDataList.get(0);
custodianOrgId = (String) data.get(Constants.VALUE.toLowerCase());
}
redisCacheMgr.putCache(Constants.CUSTODIAN_ORG_ID, custodianOrgId);
redisCacheMgr.putStringInCache(Constants.CUSTODIAN_ORG_ID, custodianOrgId);
}
return custodianOrgId;
}
Expand All @@ -831,7 +831,7 @@ public String getCustodianOrgChannel() {
Map<String, Object> data = existingDataList.get(0);
custodianOrgChannel = (String) data.get(Constants.VALUE.toLowerCase());
}
redisCacheMgr.putCache(Constants.CUSTODIAN_ORG_CHANNEL, custodianOrgChannel);
redisCacheMgr.putStringInCache(Constants.CUSTODIAN_ORG_CHANNEL, custodianOrgChannel);
}
return custodianOrgChannel;
}
Expand Down

0 comments on commit 4b769bd

Please sign in to comment.