Skip to content

Commit

Permalink
Removed usage of redis cache in explore course API
Browse files Browse the repository at this point in the history
  • Loading branch information
karthik-tarento committed Aug 26, 2022
1 parent 17429a9 commit 7e1ca1e
Showing 1 changed file with 11 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,29 +53,18 @@ public SBApiResponse getExploreCourseList() {
SBApiResponse response = ProjectUtil.createDefaultResponse(Constants.API_GET_EXPLORE_COURSE_DETAIL);
String errMsg = "";
try {
Map<String, Object> responseCourseList = (Map<String, Object>) redisCacheMgr
.getCache(Constants.PUBLIC_COURSE_LIST);

if (ObjectUtils.isEmpty(responseCourseList)) {
List<Map<String, Object>> courseList = cassandraOperation.getRecordsByProperties(
Constants.SUNBIRD_KEY_SPACE_NAME, Constants.TABLE_EXPLORE_COURSE_LIST, MapUtils.EMPTY_MAP,
ListUtils.EMPTY_LIST);
List<String> identifierList = new ArrayList<String>();
for (Map<String, Object> course : courseList) {
identifierList.add((String) course.get(Constants.IDENTIFIER));
}
Map<String, Object> searchResponse = searchContent(identifierList);
if (!Constants.OK.equalsIgnoreCase((String) searchResponse.get(Constants.RESPONSE_CODE))) {
errMsg = "Failed to get contant details for Identifier List from DB.";
} else {
responseCourseList = (Map<String, Object>) searchResponse.get(Constants.RESULT);
redisCacheMgr.putCache(Constants.PUBLIC_COURSE_LIST, responseCourseList);
response.setResult(responseCourseList);
logger.info(String.format(
"Adding open course details into Cache. CourseId Count: %s, ContentSearch Count: %s",
identifierList.size(), responseCourseList.get(Constants.COUNT)));
}
List<Map<String, Object>> courseList = cassandraOperation.getRecordsByProperties(
Constants.SUNBIRD_KEY_SPACE_NAME, Constants.TABLE_EXPLORE_COURSE_LIST, MapUtils.EMPTY_MAP,
ListUtils.EMPTY_LIST);
List<String> identifierList = new ArrayList<String>();
for (Map<String, Object> course : courseList) {
identifierList.add((String) course.get(Constants.IDENTIFIER));
}
Map<String, Object> searchResponse = searchContent(identifierList);
if (!Constants.OK.equalsIgnoreCase((String) searchResponse.get(Constants.RESPONSE_CODE))) {
errMsg = "Failed to get contant details for Identifier List from DB.";
} else {
Map<String, Object> responseCourseList = (Map<String, Object>) searchResponse.get(Constants.RESULT);
response.setResult(responseCourseList);
}
} catch (Exception e) {
Expand Down

0 comments on commit 7e1ca1e

Please sign in to comment.