Skip to content

Commit

Permalink
fixing cache timeout setting
Browse files Browse the repository at this point in the history
  • Loading branch information
sidgupta committed Mar 29, 2016
1 parent d885dd3 commit c8b76f1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions caravel/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,14 @@ def get_json(self):
logging.info("Serving from cache")
else:
is_cached = False
cache_timeout = self.cache_timeout
config_cache_timeout = config.get("CACHE_DEFAULT_TIMEOUT")
try:
cache_timeout = self.cache_timeout
except Exception as e:
if config_cache_timeout:
cache_timeout = config_cache_timeout
else:
cache_timeout = 0
payload = {
'data': self.get_data(),
'query': self.query,
Expand All @@ -246,7 +253,7 @@ def get_json(self):
payload['cached_dttm'] = datetime.now().isoformat().split('.')[0]
logging.info("Caching for the next {} seconds".format(
cache_timeout))
cache.set(cache_key, payload, timeout=self.cache_timeout)
cache.set(cache_key, payload, timeout=cache_timeout)
payload['is_cached'] = is_cached
return dumps(payload)

Expand Down

0 comments on commit c8b76f1

Please sign in to comment.