Make RestrictedDataCache optional

This commit is contained in:
Oskar Hahn 2017-09-14 07:19:56 +02:00 committed by FinnStutzenstein
parent 7eaa388747
commit faf44602cb
2 changed files with 10 additions and 1 deletions

View File

@ -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()

View File

@ -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/