Skip to content

Commit

Permalink
Merge pull request #133 from ractf/hotfix/cache-invalidation
Browse files Browse the repository at this point in the history
Invalidate challenge cache when a challenge is deleted.
  • Loading branch information
jchristgit authored Jul 23, 2021
2 parents fbbe8ec + 164cc6c commit e473b8a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/challenge/signals.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from django.core.cache import caches
from django.db.models.signals import post_save
from django.db.models.signals import post_save, post_delete
from django.dispatch import receiver

from challenge.models import Challenge


@receiver(post_save, sender=Challenge)
def challenge_save(sender, instance, **kwargs):
@receiver([post_save, post_delete], sender=Challenge)
def challenge_cache_invalidate(sender, instance, **kwargs):
new_index = caches["default"].get("challenge_mod_index", 0) + 1
caches["default"].set("challenge_mod_index", new_index)

0 comments on commit e473b8a

Please sign in to comment.