diff --git a/openslides/utils/cache.py b/openslides/utils/cache.py index 04db952db..518da51f2 100644 --- a/openslides/utils/cache.py +++ b/openslides/utils/cache.py @@ -15,6 +15,7 @@ from typing import ( # noqa from channels import Group from channels.sessions import session_for_reply_channel +from django.conf import settings from django.core.cache import cache, caches if TYPE_CHECKING: @@ -296,7 +297,10 @@ def get_redis_connection() -> Any: if use_redis_cache(): websocket_user_cache = RedisWebsocketUserCache() # type: BaseWebsocketUserCache - restricted_data_cache = RestrictedDataCache() # type: Union[RestrictedDataCache, DummyRestrictedDataCache] + if settings.DISABLE_USER_CACHE: + restricted_data_cache = DummyRestrictedDataCache() # type: Union[RestrictedDataCache, DummyRestrictedDataCache] + else: + restricted_data_cache = RestrictedDataCache() else: websocket_user_cache = DjangoCacheWebsocketUserCache() restricted_data_cache = DummyRestrictedDataCache() diff --git a/openslides/utils/settings.py.tpl b/openslides/utils/settings.py.tpl index 542b38313..41d5b548d 100644 --- a/openslides/utils/settings.py.tpl +++ b/openslides/utils/settings.py.tpl @@ -112,6 +112,11 @@ if use_redis: SESSION_ENGINE = 'redis_sessions.session' +# When use_redis is True, the restricted data cache caches the data individuel +# for each user. This requires a lot of memory if there are a lot of active +# users. If use_redis is False, this setting has no effect. +DISABLE_USER_CACHE = False + # Internationalization # https://docs.djangoproject.com/en/1.10/topics/i18n/