from django.db.models.signals import post_save
from django.dispatch import receiver
from django.core.cache import cache
from ..models.cacheconfig import CacheConfig


@receiver(post_save, sender=CacheConfig)
def refresh_cache_settings(sender, instance, **kwargs):
    # 更新后清理所有缓存
    cache.disconnect_all()
    # 重新初始化缓存连接
    from django.core.cache import caches
    caches.all()
