Skip to content

Commit

Permalink
Merge pull request #1680 from redbaron/zero-cacheTimeout-equals-noCache
Browse files Browse the repository at this point in the history
Make cacheTimeout == 0 equal to noCache being set to True
  • Loading branch information
obfuscurity committed Sep 7, 2016
2 parents 998b729 + d171767 commit 722a3df
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions webapp/graphite/render/views.py
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 722a3df

Please sign in to comment.