Skip to content

Commit

Permalink
Make sure cache.set never fails hard (#611)
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch authored Jun 13, 2016
1 parent 9ed8c32 commit 267c019
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion caravel/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,12 @@ 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=cache_timeout)
try:
cache.set(cache_key, payload, timeout=cache_timeout)
except Exception as e:
# cache.set call can fail if the backend is down or if
# the key is too large or whatever other reasons
logging.warning("Could not cache key {}".format(cache_key))
payload['is_cached'] = is_cached
return self.json_dumps(payload)

Expand Down

0 comments on commit 267c019

Please sign in to comment.