Skip to content
Snippets Groups Projects
Commit 140c71b4 authored by Daniel Gerhardt's avatar Daniel Gerhardt
Browse files

Clear caches at fixed time intervals

parent d31140b9
1 merge request!30Clear caches at fixed time intervals
Pipeline #3446 passed with stages
in 2 minutes and 18 seconds
...@@ -19,6 +19,7 @@ package de.thm.arsnova.cache; ...@@ -19,6 +19,7 @@ package de.thm.arsnova.cache;
import de.thm.arsnova.events.*; import de.thm.arsnova.events.*;
import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CacheEvict;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
/** /**
......
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() { }
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment