diff --git a/src/main/java/de/thm/arsnova/cache/CacheBuster.java b/src/main/java/de/thm/arsnova/cache/CacheBuster.java index 9ea458b36f5a443c37057400eccc99f3693578e1..5291d6ee9f3def6b8c5850e5694a642d4f959e88 100644 --- a/src/main/java/de/thm/arsnova/cache/CacheBuster.java +++ b/src/main/java/de/thm/arsnova/cache/CacheBuster.java @@ -19,6 +19,7 @@ package de.thm.arsnova.cache; import de.thm.arsnova.events.*; import org.springframework.cache.annotation.CacheEvict; +import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; /** diff --git a/src/main/java/de/thm/arsnova/cache/ScheduledCacheBuster.java b/src/main/java/de/thm/arsnova/cache/ScheduledCacheBuster.java new file mode 100644 index 0000000000000000000000000000000000000000..5c49dfc37b5ebc0e4210d8a445699451cec1832d --- /dev/null +++ b/src/main/java/de/thm/arsnova/cache/ScheduledCacheBuster.java @@ -0,0 +1,52 @@ +package de.thm.arsnova.cache; + +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +/** This component cleares caches at fixed time intervals: + * <ul> + * <li><code>sessions</code>: 6h</li> + * <li><code>skillquestions</code>, <code>lecturequestions</code>, <code>preparationquestions</code>, + * <code>flashcardquestions</code>: 30min</li> + * <li><code>questions</code>: 30min</li> + * <li><code>answers</code>: 15min</li> + * <li><code>learningprogress</code>: 15min</li> + * </ul> + */ +@Component +public class ScheduledCacheBuster { + + @CacheEvict(value = "sessions", allEntries = true) + @Scheduled(initialDelay = 1000 * 25, fixedRate = 1000 * 60 * 60 * 6) + private void clearSessionCache() { } + + @CacheEvict(value = "questions", allEntries = true) + @Scheduled(initialDelay = 1000 * 50, fixedRate = 1000 * 60 * 30) + private void clearQuestionCache() { } + + @CacheEvict(value = "skillquestions", allEntries = true) + @Scheduled(initialDelay = 1000 * 75, fixedRate = 1000 * 60 * 30) + private void clearSkillQuestionCache() { } + + @CacheEvict(value = "lecturequestions", allEntries = true) + @Scheduled(initialDelay = 1000 * 100, fixedRate = 1000 * 60 * 30) + private void clearLectureQuestionCache() { } + + @CacheEvict(value = "preparationquestions", allEntries = true) + @Scheduled(initialDelay = 1000 * 125, fixedRate = 1000 * 60 * 30) + private void clearPreparationQuestionCache() { } + + @CacheEvict(value = "flashcardquestions", allEntries = true) + @Scheduled(initialDelay = 1000 * 150, fixedRate = 1000 * 60 * 30) + private void clearFlashcardQuestionCache() { } + + @CacheEvict(value = "answers", allEntries = true) + @Scheduled(initialDelay = 1000 * 175, fixedRate = 1000 * 60 * 15) + private void clearAnswerCache() { } + + @CacheEvict(value = "learningprogress", allEntries = true) + @Scheduled(initialDelay = 1000 * 200, fixedRate = 1000 * 60 * 15) + private void clearLearningProgressCache() { } + +}