fixed exams for exam list must be up to date (evict cache)

This commit is contained in:
anhefti 2020-11-24 15:01:26 +01:00
parent e4995254f4
commit a5e65a2ff2
2 changed files with 14 additions and 0 deletions

View file

@ -110,6 +110,18 @@ public class ExamSessionCacheService {
return exam;
}
@CacheEvict(
cacheNames = CACHE_NAME_RUNNING_EXAM,
key = "#examId")
public Long evict(final Long examId) {
if (log.isDebugEnabled()) {
log.debug("Conditional eviction of running Exam from cache: {}", examId);
}
return examId;
}
public boolean isRunning(final Exam exam) {
if (exam == null) {
return false;

View file

@ -222,8 +222,10 @@ public class ExamSessionServiceImpl implements ExamSessionService {
@Override
public Result<Collection<Exam>> getRunningExamsForInstitution(final Long institutionId) {
// NOTE: we evict the exam from the cache (if present) to ensure user is seeing always the current state of the Exam
return this.examDAO.allIdsOfInstitution(institutionId)
.map(col -> col.stream()
.map(this.examSessionCacheService::evict)
.map(this::getRunningExam)
.filter(Result::hasValue)
.map(Result::get)