public async Task <IActionResult> ViewStudentById(int studentId) { StudentModel student = null; string loadLocation = null; string isCacheData = null; student = await _cache.GetEntryAsync <StudentModel>(studentId.ToString()); if (student is null) { if (await _db.IsValidStudentId(studentId) == false) { return(RedirectToAction("Alert")); } student = await _db.GetStudentById(studentId); loadLocation = "Data loaded from SQL database"; isCacheData = "text-success"; await _cache.SetEntryAsync(studentId.ToString(), student); } else { loadLocation = "Data loaded form Redis Cache"; isCacheData = "text-danger"; } StudentDisplayModel displayStudent = new StudentDisplayModel { StudentId = student.StudentId, FirstName = student.FirstName, LastName = student.LastName, Email = student.Email }; TempData["loadLocation"] = loadLocation; TempData["isCacheData"] = isCacheData; return(View(displayStudent)); }