Merge pull request #3403 from ostcar/optional_restricted_data_cache
Make RestrictedDataCache optional
This commit is contained in:
commit
83f67b23c9
@ -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()
|
||||
|
@ -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/
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user