Permalink
Browse files

Merge pull request #1680 from redbaron/zero-cacheTimeout-equals-noCache

Make cacheTimeout == 0 equal to noCache being set to True
  • Loading branch information...
2 parents 998b729 + d171767 commit 722a3df131216980351de2ada424081eb4833778 @obfuscurity obfuscurity committed on GitHub Sep 7, 2016
Showing with 7 additions and 2 deletions.
  1. +7 −2 webapp/graphite/render/views.py
@@ -294,7 +294,7 @@ def parseOptions(request):
requestOptions['graphType'] = graphType
requestOptions['graphClass'] = graphClass
requestOptions['pieMode'] = queryParams.get('pieMode', 'average')
- requestOptions['cacheTimeout'] = int( queryParams.get('cacheTimeout', settings.DEFAULT_CACHE_DURATION) )
+ cacheTimeout = int( queryParams.get('cacheTimeout', settings.DEFAULT_CACHE_DURATION) )
requestOptions['targets'] = []
# Extract the targets out of the queryParams
@@ -376,7 +376,12 @@ def parseOptions(request):
timeRange = endTime - startTime
queryTime = timeRange.days * 86400 + timeRange.seconds # convert the time delta to seconds
if settings.DEFAULT_CACHE_POLICY and not queryParams.get('cacheTimeout'):
- requestOptions['cacheTimeout'] = max(timeout for period,timeout in settings.DEFAULT_CACHE_POLICY if period <= queryTime)
+ timeouts = [timeout for period,timeout in settings.DEFAULT_CACHE_POLICY if period <= queryTime]
+ cacheTimeout = max(timeouts or (0,))
+
+ if cacheTimeout == 0:
+ requestOptions['noCache'] = True
+ requestOptions['cacheTimeout'] = cacheTimeout
return (graphOptions, requestOptions)

0 comments on commit 722a3df

Please sign in to comment.