diff options
author | Matthew Lemon <matt@matthewlemon.com> | 2020-03-10 21:00:46 +0000 |
---|---|---|
committer | Matthew Lemon <matt@matthewlemon.com> | 2020-03-10 21:00:46 +0000 |
commit | 136108c68262da639cac54cda39c286f9dac8a4f (patch) | |
tree | 67fd063f8f765e3f8bca2e6c49c680f96992bb18 | |
parent | 274b7642e9297baecfeb044e9fd20e3f50f04fc9 (diff) |
implemented basic database cache
Diffstat (limited to '')
-rw-r--r-- | config/settings/base.py | 10 | ||||
-rw-r--r-- | ctrack/caf/urls.py | 3 |
2 files changed, 12 insertions, 1 deletions
diff --git a/config/settings/base.py b/config/settings/base.py index 83317ca..865ea99 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -54,6 +54,16 @@ ROOT_URLCONF = "config.urls" # https://docs.djangoproject.com/en/dev/ref/settings/#wsgi-application WSGI_APPLICATION = "config.wsgi.application" +# CACHE +# We're going to use the database here + +CACHES = { + 'default': { + 'BACKEND': 'django.core.cache.backends.db.DatabaseCache', + 'LOCATION': 'ctrack_cache_table', + } +} + # APPS # ------------------------------------------------------------------------------ DJANGO_APPS = [ diff --git a/ctrack/caf/urls.py b/ctrack/caf/urls.py index 3016013..dc228ae 100644 --- a/ctrack/caf/urls.py +++ b/ctrack/caf/urls.py @@ -1,4 +1,5 @@ from django.urls import path +from django.views.decorators.cache import cache_page from ctrack.caf.views import CreateCAF, ListCAF, ListApplicableSystem, DetailCAF @@ -7,6 +8,6 @@ app_name = "caf" urlpatterns = [ path("", view=CreateCAF.as_view(), name="create"), path("", view=ListCAF.as_view(), name="caf_list"), - path("applicablesystems", view=ListApplicableSystem.as_view(), name="es_list"), + path("applicablesystems", cache_page(60 * 60)(ListApplicableSystem.as_view()), name="es_list"), path("<int:pk>", DetailCAF.as_view(), name="detail") ] |