Add redis support
parent
4d1b4cfaec
commit
1e4f34fd97
|
@ -1,2 +0,0 @@
|
||||||
db/static/js/lib/
|
|
||||||
staticfiles/
|
|
|
@ -11,6 +11,7 @@ from django.http import HttpResponseNotFound, HttpResponseServerError, HttpRespo
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.sites.shortcuts import get_current_site
|
from django.contrib.sites.shortcuts import get_current_site
|
||||||
from django.template.loader import render_to_string
|
from django.template.loader import render_to_string
|
||||||
|
from django.views.decorators.cache import cache_page
|
||||||
|
|
||||||
from db.base.models import Mode, Transmitter, Satellite, Suggestion
|
from db.base.models import Mode, Transmitter, Satellite, Suggestion
|
||||||
from db.base.forms import SuggestionForm
|
from db.base.forms import SuggestionForm
|
||||||
|
@ -18,6 +19,7 @@ from db.base.forms import SuggestionForm
|
||||||
logger = logging.getLogger('db')
|
logger = logging.getLogger('db')
|
||||||
|
|
||||||
|
|
||||||
|
@cache_page(settings.CACHE_TTL)
|
||||||
def home(request):
|
def home(request):
|
||||||
"""View to render home page."""
|
"""View to render home page."""
|
||||||
satellites = Satellite.objects.all()
|
satellites = Satellite.objects.all()
|
||||||
|
@ -131,6 +133,7 @@ def stats(request):
|
||||||
return render(request, 'base/stats.html')
|
return render(request, 'base/stats.html')
|
||||||
|
|
||||||
|
|
||||||
|
@cache_page(settings.CACHE_TTL)
|
||||||
def statistics(request):
|
def statistics(request):
|
||||||
"""View to create statistics endpoint."""
|
"""View to create statistics endpoint."""
|
||||||
satellites = Satellite.objects.all()
|
satellites = Satellite.objects.all()
|
||||||
|
|
|
@ -57,6 +57,7 @@ CACHES = {
|
||||||
'LOCATION': 'unique-snowflake'
|
'LOCATION': 'unique-snowflake'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
CACHE_TTL = getenv('CACHE_TTL', 300)
|
||||||
|
|
||||||
# Internationalization
|
# Internationalization
|
||||||
TIME_ZONE = 'UTC'
|
TIME_ZONE = 'UTC'
|
||||||
|
|
|
@ -12,6 +12,18 @@ INSTALLED_APPS = INSTALLED_APPS + (
|
||||||
'opbeat.contrib.django',
|
'opbeat.contrib.django',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Cache
|
||||||
|
CACHES = {
|
||||||
|
'default': {
|
||||||
|
'BACKEND': 'redis_cache.RedisCache',
|
||||||
|
'LOCATION': 'unix:/var/run/redis/redis.sock',
|
||||||
|
'OPTIONS': {
|
||||||
|
'CLIENT_CLASS': 'django_redis.client.DefaultClient'
|
||||||
|
},
|
||||||
|
'KEY_PREFIX': 'db-{0}'.format(ENVIRONMENT)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Security
|
# Security
|
||||||
SECURE_HSTS_SECONDS = 60
|
SECURE_HSTS_SECONDS = 60
|
||||||
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
|
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
|
||||||
|
|
|
@ -12,6 +12,18 @@ INSTALLED_APPS = INSTALLED_APPS + (
|
||||||
'opbeat.contrib.django',
|
'opbeat.contrib.django',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Cache
|
||||||
|
CACHES = {
|
||||||
|
'default': {
|
||||||
|
'BACKEND': 'redis_cache.RedisCache',
|
||||||
|
'LOCATION': 'unix:/var/run/redis/redis.sock',
|
||||||
|
'OPTIONS': {
|
||||||
|
'CLIENT_CLASS': 'django_redis.client.DefaultClient'
|
||||||
|
},
|
||||||
|
'KEY_PREFIX': 'db-{0}'.format(ENVIRONMENT)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Security
|
# Security
|
||||||
ALLOWED_HOSTS = [
|
ALLOWED_HOSTS = [
|
||||||
os.getenv('ALLOWED_HOSTS', '*')
|
os.getenv('ALLOWED_HOSTS', '*')
|
||||||
|
|
|
@ -5,6 +5,10 @@ django-compressor==2.1.1
|
||||||
django-jsonfield==1.0.1
|
django-jsonfield==1.0.1
|
||||||
django-bower==5.2.0
|
django-bower==5.2.0
|
||||||
|
|
||||||
|
# Cache
|
||||||
|
redis==2.10.5
|
||||||
|
django-redis-cache==1.7.1
|
||||||
|
|
||||||
# Configuration
|
# Configuration
|
||||||
django-dotenv==1.4.1
|
django-dotenv==1.4.1
|
||||||
dj-database-url==0.4.2
|
dj-database-url==0.4.2
|
||||||
|
|
Loading…
Reference in New Issue