-
Notifications
You must be signed in to change notification settings - Fork 13.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: rename TABLE_NAMES_CACHE_CONFIG to DATA_CACHE_CONFIG #11509
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ __pycache__ | |
cover | ||
.DS_Store | ||
.eggs | ||
.env | ||
.envrc | ||
.idea | ||
.mypy_cache | ||
|
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,11 +24,12 @@ | |
import pandas as pd | ||
from flask_babel import gettext as _ | ||
|
||
from superset import app, cache, db, is_feature_enabled, security_manager | ||
from superset import app, db, is_feature_enabled | ||
from superset.common.query_object import QueryObject | ||
from superset.connectors.base.models import BaseDatasource | ||
from superset.connectors.connector_registry import ConnectorRegistry | ||
from superset.exceptions import QueryObjectValidationError | ||
from superset.extensions import cache_manager, security_manager | ||
from superset.stats_logger import BaseStatsLogger | ||
from superset.utils import core as utils | ||
from superset.utils.core import DTTM_ALIAS | ||
|
@@ -233,8 +234,8 @@ def get_df_payload( # pylint: disable=too-many-statements | |
status = None | ||
query = "" | ||
error_message = None | ||
if cache_key and cache and not self.force: | ||
cache_value = cache.get(cache_key) | ||
if cache_key and cache_manager.data_cache and not self.force: | ||
cache_value = cache_manager.data_cache.get(cache_key) | ||
if cache_value: | ||
stats_logger.incr("loading_from_cache") | ||
try: | ||
|
@@ -286,7 +287,7 @@ def get_df_payload( # pylint: disable=too-many-statements | |
status = utils.QueryStatus.FAILED | ||
stacktrace = utils.get_stacktrace() | ||
|
||
if is_loaded and cache_key and cache and status != utils.QueryStatus.FAILED: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if is_loaded and cache_key and status != utils.QueryStatus.FAILED: | ||
set_and_log_cache( | ||
cache_key, | ||
df, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,8 +54,9 @@ | |
from sqlalchemy.sql import expression, Select | ||
from sqlalchemy_utils import EncryptedType | ||
|
||
from superset import app, db_engine_specs, is_feature_enabled, security_manager | ||
from superset import app, db_engine_specs, is_feature_enabled | ||
from superset.db_engine_specs.base import TimeGrain | ||
from superset.extensions import cache_manager, security_manager | ||
from superset.models.helpers import AuditMixinNullable, ImportExportMixin | ||
from superset.models.tags import FavStarUpdater | ||
from superset.result_set import SupersetResultSet | ||
|
@@ -452,8 +453,8 @@ def inspector(self) -> Inspector: | |
return sqla.inspect(engine) | ||
|
||
@cache_util.memoized_func( | ||
key=lambda *args, **kwargs: "db:{}:schema:None:table_list", | ||
attribute_in_key="id", | ||
key=lambda self, *args, **kwargs: f"db:{self.id}:schema:None:table_list", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A small refactor to make the memoize function more flexible. |
||
cache=cache_manager.data_cache, | ||
) | ||
def get_all_table_names_in_database( | ||
self, | ||
|
@@ -467,7 +468,8 @@ def get_all_table_names_in_database( | |
return self.db_engine_spec.get_all_datasource_names(self, "table") | ||
|
||
@cache_util.memoized_func( | ||
key=lambda *args, **kwargs: "db:{}:schema:None:view_list", attribute_in_key="id" | ||
key=lambda self, *args, **kwargs: f"db:{self.id}:schema:None:view_list", | ||
cache=cache_manager.data_cache, | ||
) | ||
def get_all_view_names_in_database( | ||
self, | ||
|
@@ -481,8 +483,8 @@ def get_all_view_names_in_database( | |
return self.db_engine_spec.get_all_datasource_names(self, "view") | ||
|
||
@cache_util.memoized_func( | ||
key=lambda *args, **kwargs: f"db:{{}}:schema:{kwargs.get('schema')}:table_list", # type: ignore | ||
attribute_in_key="id", | ||
key=lambda self, schema, *args, **kwargs: f"db:{self.id}:schema:{schema}:table_list", # type: ignore | ||
cache=cache_manager.data_cache, | ||
) | ||
def get_all_table_names_in_schema( | ||
self, | ||
|
@@ -513,8 +515,8 @@ def get_all_table_names_in_schema( | |
logger.warning(ex) | ||
|
||
@cache_util.memoized_func( | ||
key=lambda *args, **kwargs: f"db:{{}}:schema:{kwargs.get('schema')}:view_list", # type: ignore | ||
attribute_in_key="id", | ||
key=lambda self, schema, *args, **kwargs: f"db:{self.id}:schema:{schema}:view_list", # type: ignore | ||
cache=cache_manager.data_cache, | ||
) | ||
def get_all_view_names_in_schema( | ||
self, | ||
|
@@ -543,7 +545,8 @@ def get_all_view_names_in_schema( | |
logger.warning(ex) | ||
|
||
@cache_util.memoized_func( | ||
key=lambda *args, **kwargs: "db:{}:schema_list", attribute_in_key="id" | ||
key=lambda self, *args, **kwargs: f"db:{self.id}:schema_list", | ||
cache=cache_manager.data_cache, | ||
) | ||
def get_all_schema_names( | ||
self, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import the
cache_manager
instead ofcache
to make it clear which cache we are using.