mirror of
https://github.com/apache/superset.git
synced 2024-09-12 08:39:45 -04:00
[hotfix] adding cache_key in payload
This commit is contained in:
parent
7d90f26554
commit
37be01bc12
@ -134,3 +134,7 @@ try:
|
|||||||
from caravel_config import * # noqa
|
from caravel_config import * # noqa
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
if not CACHE_DEFAULT_TIMEOUT:
|
||||||
|
CACHE_DEFAULT_TIMEOUT = CACHE_CONFIG.get('CACHE_DEFAULT_TIMEOUT')
|
||||||
|
|
||||||
|
@ -224,12 +224,14 @@ class BaseViz(object):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def cache_timeout(self):
|
def cache_timeout(self):
|
||||||
|
|
||||||
if self.slice and self.slice.cache_timeout:
|
if self.slice and self.slice.cache_timeout:
|
||||||
return self.slice.cache_timeout
|
return self.slice.cache_timeout
|
||||||
if self.datasource.cache_timeout:
|
if self.datasource.cache_timeout:
|
||||||
return self.datasource.cache_timeout
|
return self.datasource.cache_timeout
|
||||||
if hasattr(self.datasource, 'database') \
|
if (
|
||||||
and self.datasource.database.cache_timeout:
|
hasattr(self.datasource, 'database') and
|
||||||
|
self.datasource.database.cache_timeout):
|
||||||
return self.datasource.database.cache_timeout
|
return self.datasource.database.cache_timeout
|
||||||
return config.get("CACHE_DEFAULT_TIMEOUT")
|
return config.get("CACHE_DEFAULT_TIMEOUT")
|
||||||
|
|
||||||
@ -247,6 +249,7 @@ class BaseViz(object):
|
|||||||
cache_timeout = self.cache_timeout
|
cache_timeout = self.cache_timeout
|
||||||
payload = {
|
payload = {
|
||||||
'cache_timeout': cache_timeout,
|
'cache_timeout': cache_timeout,
|
||||||
|
'cache_key': cache_key,
|
||||||
'csv_endpoint': self.csv_endpoint,
|
'csv_endpoint': self.csv_endpoint,
|
||||||
'data': self.get_data(),
|
'data': self.get_data(),
|
||||||
'form_data': self.form_data,
|
'form_data': self.form_data,
|
||||||
@ -257,7 +260,7 @@ class BaseViz(object):
|
|||||||
payload['cached_dttm'] = datetime.now().isoformat().split('.')[0]
|
payload['cached_dttm'] = datetime.now().isoformat().split('.')[0]
|
||||||
logging.info("Caching for the next {} seconds".format(
|
logging.info("Caching for the next {} seconds".format(
|
||||||
cache_timeout))
|
cache_timeout))
|
||||||
cache.set(cache_key, payload, timeout=self.cache_timeout)
|
cache.set(cache_key, payload, timeout=cache_timeout)
|
||||||
payload['is_cached'] = is_cached
|
payload['is_cached'] = is_cached
|
||||||
return self.json_dumps(payload)
|
return self.json_dumps(payload)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user