From 935e37a06189b6c5b396b7ff6a3a452e4bcb446f Mon Sep 17 00:00:00 2001 From: Cameron Hyde Date: Sat, 4 Jan 2025 13:13:35 +1000 Subject: [PATCH] Skip cache in CLI_DEV mode --- app/labs/cache.py | 7 ++++++- app/labs/views.py | 6 ++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/labs/cache.py b/app/labs/cache.py index 99dc4a4..f304434 100644 --- a/app/labs/cache.py +++ b/app/labs/cache.py @@ -17,7 +17,10 @@ class LabCache: @classmethod def get(cls, request): - if request.GET.get('cache', '').lower() == 'false': + if ( + request.GET.get('cache', '').lower() == 'false' + or settings.CLI_DEV + ): return cache_key = cls._generate_cache_key(request) @@ -63,6 +66,8 @@ class WebCache: @classmethod def get(cls, url): + if settings.CLI_DEV: + return cache_key = cls._generate_cache_key(url) data = cache.get(cache_key) if data: diff --git a/app/labs/views.py b/app/labs/views.py index 71af77b..2b27ac6 100644 --- a/app/labs/views.py +++ b/app/labs/views.py @@ -30,10 +30,8 @@ def export_lab(request): an ad hoc basis, where the content would typically be hosted in a GitHub repo with a YAML file root which is specified as a GET parameter. """ - - if not settings.CLI_DEV: - if response := LabCache.get(request): - return response + if response := LabCache.get(request): + return response template = 'labs/exported.html'