Skip to content
Snippets Groups Projects
Verified Commit 5903e600 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Invalidate both database backends

parent 4f1ee633
No related branches found
No related tags found
1 merge request!963Invalidate both database backends
Pipeline #54143 passed
...@@ -15,6 +15,7 @@ Fixed ...@@ -15,6 +15,7 @@ Fixed
* Inviting newly created persons for registration failed * Inviting newly created persons for registration failed
* [Docker] Do not clear cache in migration container die to session invalidation issues * [Docker] Do not clear cache in migration container die to session invalidation issues
* Notification email about user changes was broken * Notification email about user changes was broken
* SQL cache invalidation could fail when hitting OOT database
`2.7.3`_ - 2022-02-03 `2.7.3`_ - 2022-02-03
--------------------- ---------------------
......
...@@ -17,6 +17,8 @@ from django.utils.crypto import get_random_string ...@@ -17,6 +17,8 @@ from django.utils.crypto import get_random_string
from django.utils.functional import lazy from django.utils.functional import lazy
from django.utils.module_loading import import_string from django.utils.module_loading import import_string
from cachalot.api import invalidate
from cachalot.signals import post_invalidation
from cache_memoize import cache_memoize from cache_memoize import cache_memoize
...@@ -403,6 +405,8 @@ class OOTRouter: ...@@ -403,6 +405,8 @@ class OOTRouter:
default_db = "default" default_db = "default"
oot_db = "default_oot" oot_db = "default_oot"
_cachalot_invalidating = []
@property @property
def oot_labels(self): def oot_labels(self):
return settings.DATABASE_OOT_LABELS return settings.DATABASE_OOT_LABELS
...@@ -441,3 +445,20 @@ class OOTRouter: ...@@ -441,3 +445,20 @@ class OOTRouter:
return False return False
return None return None
@classmethod
def _invalidate_cachalot(cls, sender, **kwargs):
if sender in cls._cachalot_invalidating:
return
cls._cachalot_invalidating.append(sender)
if kwargs["db_alias"] == cls.default_db:
invalidate(sender, db_alias=cls.oot_db)
elif kwargs["db_alias"] == cls.oot_db:
invalidate(sender, db_alias=cls.default_db)
if sender in cls._cachalot_invalidating:
cls._cachalot_invalidating.remove(sender)
post_invalidation.connect(OOTRouter._invalidate_cachalot)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment