From c8b76f19095be3e6996e1f24e210df1eea805b58 Mon Sep 17 00:00:00 2001 From: sidgupta Date: Tue, 29 Mar 2016 13:53:52 -0700 Subject: [PATCH] fixing cache timeout setting --- caravel/viz.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/caravel/viz.py b/caravel/viz.py index 797c5363edeb9..ec4e9adaf1c44 100644 --- a/caravel/viz.py +++ b/caravel/viz.py @@ -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, @@ -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)