add custom cache backend for deleting many keys with a pattern
This commit is contained in:
10
api/tacticalrmm/tacticalrmm/cache.py
Normal file
10
api/tacticalrmm/tacticalrmm/cache.py
Normal file
@@ -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)
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user