This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
2019-03-21 15:27:37 +00:00
|
|
|
"""passbook app_gw cache clean signals"""
|
|
|
|
|
|
|
|
from django.core.cache import cache
|
|
|
|
from django.db.models.signals import post_save
|
|
|
|
from django.dispatch import receiver
|
2019-10-01 08:24:10 +00:00
|
|
|
from structlog import get_logger
|
2019-03-21 15:27:37 +00:00
|
|
|
|
|
|
|
from passbook.app_gw.models import ApplicationGatewayProvider
|
2019-04-13 14:05:11 +00:00
|
|
|
from passbook.app_gw.proxy.handler import IGNORED_HOSTNAMES_KEY
|
2019-03-21 15:27:37 +00:00
|
|
|
|
2019-10-01 08:24:10 +00:00
|
|
|
LOGGER = get_logger(__name__)
|
2019-03-21 15:27:37 +00:00
|
|
|
|
|
|
|
@receiver(post_save)
|
|
|
|
# pylint: disable=unused-argument
|
|
|
|
def invalidate_app_gw_cache(sender, instance, **kwargs):
|
|
|
|
"""Invalidate Policy cache when app_gw is updated"""
|
|
|
|
if isinstance(instance, ApplicationGatewayProvider):
|
|
|
|
LOGGER.debug("Invalidating cache for ignored hostnames")
|
|
|
|
cache.delete(IGNORED_HOSTNAMES_KEY)
|