mirror of
https://github.com/pretix/pretix.git
synced 2026-05-08 15:44:02 +00:00
Refs #110 -- Don't use cached session storage without a central cache
This commit is contained in:
@@ -87,16 +87,17 @@ CACHES = {
|
|||||||
'LOCATION': 'unique-snowflake',
|
'LOCATION': 'unique-snowflake',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
REAL_CACHE_USED = False
|
||||||
|
SESSION_ENGINE = None
|
||||||
|
|
||||||
HAS_MEMCACHED = config.has_option('memcached', 'location')
|
HAS_MEMCACHED = config.has_option('memcached', 'location')
|
||||||
if HAS_MEMCACHED:
|
if HAS_MEMCACHED:
|
||||||
|
REAL_CACHE_USED = True
|
||||||
CACHES['default'] = {
|
CACHES['default'] = {
|
||||||
'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
|
'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
|
||||||
'LOCATION': config.get('memcached', 'location'),
|
'LOCATION': config.get('memcached', 'location'),
|
||||||
}
|
}
|
||||||
|
|
||||||
SESSION_ENGINE = "django.contrib.sessions.backends.cached_db"
|
|
||||||
|
|
||||||
HAS_REDIS = config.has_option('redis', 'location')
|
HAS_REDIS = config.has_option('redis', 'location')
|
||||||
if HAS_REDIS:
|
if HAS_REDIS:
|
||||||
CACHES['redis'] = {
|
CACHES['redis'] = {
|
||||||
@@ -108,10 +109,16 @@ if HAS_REDIS:
|
|||||||
}
|
}
|
||||||
if not HAS_MEMCACHED:
|
if not HAS_MEMCACHED:
|
||||||
CACHES['default'] = CACHES['redis']
|
CACHES['default'] = CACHES['redis']
|
||||||
|
REAL_CACHE_USED = True
|
||||||
if config.getboolean('redis', 'sessions', fallback=False):
|
if config.getboolean('redis', 'sessions', fallback=False):
|
||||||
SESSION_ENGINE = "django.contrib.sessions.backends.cache"
|
SESSION_ENGINE = "django.contrib.sessions.backends.cache"
|
||||||
SESSION_CACHE_ALIAS = "redis"
|
SESSION_CACHE_ALIAS = "redis"
|
||||||
|
|
||||||
|
if not SESSION_ENGINE and REAL_CACHE_USED:
|
||||||
|
SESSION_ENGINE = "django.contrib.sessions.backends.cached_db"
|
||||||
|
else:
|
||||||
|
SESSION_ENGINE = "django.contrib.sessions.backends.db"
|
||||||
|
|
||||||
HAS_CELERY = config.has_option('celery', 'broker')
|
HAS_CELERY = config.has_option('celery', 'broker')
|
||||||
if HAS_CELERY:
|
if HAS_CELERY:
|
||||||
BROKER_URL = config.get('celery', 'broker')
|
BROKER_URL = config.get('celery', 'broker')
|
||||||
|
|||||||
Reference in New Issue
Block a user