remind user to restart c3nav if no external cache is configured

This commit is contained in:
Laura Klünder 2017-11-10 18:36:16 +01:00
parent aa7ffab45c
commit 5976a18946
3 changed files with 13 additions and 0 deletions

View file

@ -1,4 +1,6 @@
from django.conf import settings
from django.core.management.base import BaseCommand
from django.utils.translation import ugettext_lazy as _
class Command(BaseCommand):
@ -7,3 +9,6 @@ class Command(BaseCommand):
def handle(self, *args, **options):
from c3nav.mapdata.models import MapUpdate
MapUpdate.objects.create(type='management')
if not settings.HAS_REAL_CACHE:
print(_('You have no external cache configured, so don\'t forget to restart your c3nav instance!'))

View file

@ -1,4 +1,6 @@
from django.conf import settings
from django.core.management.base import BaseCommand
from django.utils.translation import ugettext_lazy as _
from c3nav.mapdata.tasks import process_map_updates
@ -8,3 +10,6 @@ class Command(BaseCommand):
def handle(self, *args, **options):
process_map_updates()
if not settings.HAS_REAL_CACHE:
print(_('You have no external cache configured, so don\'t forget to restart your c3nav instance!'))

View file

@ -118,11 +118,13 @@ CACHES = {
'LOCATION': 'unique-snowflake',
}
}
HAS_REAL_CACHE = False
SESSION_ENGINE = "django.contrib.sessions.backends.db"
HAS_MEMCACHED = config.has_option('memcached', 'location')
if HAS_MEMCACHED:
HAS_REAL_CACHE = True
CACHES['default'] = {
'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
'LOCATION': config.get('memcached', 'location'),
@ -131,6 +133,7 @@ if HAS_MEMCACHED:
HAS_REDIS = config.has_option('redis', 'location')
if HAS_REDIS:
HAS_REAL_CACHE = True
CACHES['redis'] = {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": config.get('redis', 'location'),