diff --git a/api/tacticalrmm/tacticalrmm/cache.py b/api/tacticalrmm/tacticalrmm/cache.py new file mode 100644 index 00000000..fd3d5ef1 --- /dev/null +++ b/api/tacticalrmm/tacticalrmm/cache.py @@ -0,0 +1,10 @@ +from django.core.cache.backends.redis import RedisCache +from typing import Optional + + +class TacticalRedisCache(RedisCache): + def delete_many_pattern(self, pattern: str, version: Optional[int] = None) -> None: + keys = self._cache.get_client().keys(f":{version if version else 1}:{pattern}") + + if keys: + self._cache.delete_many(keys) diff --git a/api/tacticalrmm/tacticalrmm/settings.py b/api/tacticalrmm/tacticalrmm/settings.py index 839e8322..0d849634 100644 --- a/api/tacticalrmm/tacticalrmm/settings.py +++ b/api/tacticalrmm/tacticalrmm/settings.py @@ -151,7 +151,7 @@ CHANNEL_LAYERS = { CACHES = { "default": { - "BACKEND": "django.core.cache.backends.redis.RedisCache", + "BACKEND": "tacticalrmm.cache.TacticalRedisCache", "LOCATION": f"redis://{REDIS_HOST}:6379", "OPTIONS": { "parser_class": "redis.connection.HiredisParser",