You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
575 B
20 lines
575 B
from django.db.models.signals import post_save, post_delete
|
|
from django.dispatch import receiver
|
|
from utils.cache import invalidate_cache_patterns
|
|
from .models import CalendarOccasions
|
|
|
|
TARGET_MODELS = [CalendarOccasions]
|
|
|
|
|
|
def invalidate_calendar_cache():
|
|
"""
|
|
Invalidates all Redis cache keys for calendar API views.
|
|
"""
|
|
return invalidate_cache_patterns("*calendar_api*")
|
|
|
|
|
|
@receiver(post_save)
|
|
@receiver(post_delete)
|
|
def clear_calendar_cache_on_save_or_delete(sender, instance, **kwargs):
|
|
if sender in TARGET_MODELS:
|
|
invalidate_calendar_cache()
|