2016-10-17 18:11:16 +02:00
|
|
|
from __future__ import print_function
|
|
|
|
|
|
|
|
from django.apps import AppConfig
|
|
|
|
from django.db.models.signals import post_migrate
|
|
|
|
from django.core.cache import cache
|
|
|
|
from django.conf import settings
|
|
|
|
from typing import Any, Dict
|
|
|
|
|
|
|
|
import logging
|
|
|
|
|
2017-01-30 23:19:38 +01:00
|
|
|
|
2016-10-17 18:11:16 +02:00
|
|
|
def flush_cache(sender, **kwargs):
|
|
|
|
# type: (AppConfig, **Any) -> None
|
|
|
|
logging.info("Clearing memcached cache after migrations")
|
|
|
|
cache.clear()
|
|
|
|
|
|
|
|
|
|
|
|
class ZerverConfig(AppConfig):
|
|
|
|
name = "zerver" # type: str
|
|
|
|
|
|
|
|
def ready(self):
|
|
|
|
# type: () -> None
|
2017-01-30 23:19:38 +01:00
|
|
|
import zerver.signals
|
|
|
|
|
2016-10-17 18:11:16 +02:00
|
|
|
if settings.POST_MIGRATION_CACHE_FLUSHING:
|
|
|
|
post_migrate.connect(flush_cache, sender=self)
|