Skip to content

Commit

Permalink
Skip all cache methods when CLI dev
Browse files Browse the repository at this point in the history
  • Loading branch information
neoformit committed Jan 4, 2025
1 parent fc30510 commit edf7c31
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/labs/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,15 @@ def get(cls, request):

@classmethod
def put(cls, request, body):
if settings.CLI_DEV:
return HttpResponse(body)
logger.debug(
f"Cache PUT for {request.GET.get('content_root', 'root')}")
cache_key = cls._generate_cache_key(request)
timeout = (settings.CACHE_TIMEOUT
if request.GET.get('content_root')
else None) # No timeout for default "Docs Lab" page

cache.set(cache_key, body, timeout=timeout)
response = HttpResponse(body)
response['X-Cache-Status'] = 'MISS'
Expand Down Expand Up @@ -75,6 +78,8 @@ def get(cls, url):

@classmethod
def put(cls, url, data, timeout=3600):
if settings.CLI_DEV:
return
cache_key = cls._generate_cache_key(url)
cache.set(cache_key, data, timeout=timeout)

Expand Down

0 comments on commit edf7c31

Please sign in to comment.