add custom cache backend for deleting many keys with a pattern
This commit is contained in:
parent
2fe0b5b90d
commit
5aa7b5a337
|
@ -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",
|
||||
|
|
Loading…
Reference in New Issue