Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions caravel/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,15 @@ 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:
logging.exception(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 +254,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