Browse Source

implement cache invalidation

main
xenua 2 years ago
parent
commit
07788d1de9
Signed by: xenua
GPG Key ID: 8F93B68BD37255B8
  1. 7
      leftists/apps.py
  2. 4
      leftists/signals.py

7
leftists/apps.py

@ -1,6 +1,13 @@ @@ -1,6 +1,13 @@
from django.apps import AppConfig
from django.db.models.signals import pre_save
class LeftistsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'leftists'
def ready(self):
from . import signals
from .models import ShortLink
pre_save.connect(signals.rmcache, sender=ShortLink)

4
leftists/signals.py

@ -0,0 +1,4 @@ @@ -0,0 +1,4 @@
def rmcache(sender, **kwargs):
inst = kwargs.get("instance")
if inst.domain.fqdn in sender.cache:
del sender.cache[inst.domain.fqdn][inst.location]
Loading…
Cancel
Save