mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
chore(cache): default to SimpleCache in debug mode (#18976)
* chore(cache): default to SimpleCache in debug mode * lint * clean up type * use util * fix integration test cache configs * remove util from cache manager * remove trailing comma * fix more tests * fix truthiness check * fix tests and improve deprecation notice * fix default cache threshold * move debug check to cache_manager * remove separate getter * update docs * remove default cache config
This commit is contained in:
@@ -43,7 +43,7 @@ class TestCache(SupersetTestCase):
|
||||
@pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
|
||||
def test_no_data_cache(self):
|
||||
data_cache_config = app.config["DATA_CACHE_CONFIG"]
|
||||
app.config["DATA_CACHE_CONFIG"] = {"CACHE_TYPE": "null"}
|
||||
app.config["DATA_CACHE_CONFIG"] = {"CACHE_TYPE": "NullCache"}
|
||||
cache_manager.init_app(app)
|
||||
|
||||
slc = self.get_slice("Girls", db.session)
|
||||
@@ -68,9 +68,8 @@ class TestCache(SupersetTestCase):
|
||||
cache_default_timeout = app.config["CACHE_DEFAULT_TIMEOUT"]
|
||||
app.config["CACHE_DEFAULT_TIMEOUT"] = 100
|
||||
app.config["DATA_CACHE_CONFIG"] = {
|
||||
"CACHE_TYPE": "simple",
|
||||
"CACHE_TYPE": "SimpleCache",
|
||||
"CACHE_DEFAULT_TIMEOUT": 10,
|
||||
"CACHE_KEY_PREFIX": "superset_data_cache",
|
||||
}
|
||||
cache_manager.init_app(app)
|
||||
|
||||
|
||||
@@ -62,8 +62,6 @@ def admin_id() -> int:
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def cache(dashboard_id, admin_id):
|
||||
app.config["FILTER_STATE_CACHE_CONFIG"] = {"CACHE_TYPE": "SimpleCache"}
|
||||
cache_manager.init_app(app)
|
||||
entry: Entry = {"owner": admin_id, "value": value}
|
||||
cache_manager.filter_state_cache.set(cache_key(dashboard_id, key), entry)
|
||||
|
||||
|
||||
@@ -74,8 +74,6 @@ def dataset_id() -> int:
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def cache(chart_id, admin_id, dataset_id):
|
||||
app.config["EXPLORE_FORM_DATA_CACHE_CONFIG"] = {"CACHE_TYPE": "SimpleCache"}
|
||||
cache_manager.init_app(app)
|
||||
entry: TemporaryExploreState = {
|
||||
"owner": admin_id,
|
||||
"dataset_id": dataset_id,
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
# type: ignore
|
||||
import math
|
||||
from copy import copy
|
||||
from datetime import timedelta
|
||||
|
||||
@@ -85,10 +86,9 @@ REDIS_CELERY_DB = os.environ.get("REDIS_CELERY_DB", 2)
|
||||
REDIS_RESULTS_DB = os.environ.get("REDIS_RESULTS_DB", 3)
|
||||
REDIS_CACHE_DB = os.environ.get("REDIS_CACHE_DB", 4)
|
||||
|
||||
CACHE_DEFAULT_TIMEOUT = int(timedelta(minutes=10).total_seconds())
|
||||
|
||||
CACHE_CONFIG = {
|
||||
"CACHE_TYPE": "redis",
|
||||
"CACHE_TYPE": "RedisCache",
|
||||
"CACHE_DEFAULT_TIMEOUT": int(timedelta(minutes=1).total_seconds()),
|
||||
"CACHE_KEY_PREFIX": "superset_cache",
|
||||
"CACHE_REDIS_URL": f"redis://{REDIS_HOST}:{REDIS_PORT}/{REDIS_CACHE_DB}",
|
||||
@@ -100,6 +100,18 @@ DATA_CACHE_CONFIG = {
|
||||
"CACHE_KEY_PREFIX": "superset_data_cache",
|
||||
}
|
||||
|
||||
FILTER_STATE_CACHE_CONFIG = {
|
||||
"CACHE_TYPE": "SimpleCache",
|
||||
"CACHE_THRESHOLD": math.inf,
|
||||
"CACHE_DEFAULT_TIMEOUT": int(timedelta(minutes=10).total_seconds()),
|
||||
}
|
||||
|
||||
EXPLORE_FORM_DATA_CACHE_CONFIG = {
|
||||
"CACHE_TYPE": "SimpleCache",
|
||||
"CACHE_THRESHOLD": math.inf,
|
||||
"CACHE_DEFAULT_TIMEOUT": int(timedelta(minutes=10).total_seconds()),
|
||||
}
|
||||
|
||||
GLOBAL_ASYNC_QUERIES_JWT_SECRET = "test-secret-change-me-test-secret-change-me"
|
||||
|
||||
ALERT_REPORTS_WORKING_TIME_OUT_KILL = True
|
||||
|
||||
@@ -53,7 +53,7 @@ PUBLIC_ROLE_LIKE = "Gamma"
|
||||
AUTH_ROLE_PUBLIC = "Public"
|
||||
EMAIL_NOTIFICATIONS = False
|
||||
|
||||
CACHE_CONFIG = {"CACHE_TYPE": "simple"}
|
||||
CACHE_CONFIG = {"CACHE_TYPE": "SimpleCache"}
|
||||
|
||||
REDIS_HOST = os.environ.get("REDIS_HOST", "localhost")
|
||||
REDIS_PORT = os.environ.get("REDIS_PORT", "6379")
|
||||
@@ -79,7 +79,7 @@ FEATURE_FLAGS = {
|
||||
}
|
||||
|
||||
THUMBNAIL_CACHE_CONFIG = {
|
||||
"CACHE_TYPE": "redis",
|
||||
"CACHE_TYPE": "RedisCache",
|
||||
"CACHE_DEFAULT_TIMEOUT": 10000,
|
||||
"CACHE_KEY_PREFIX": "superset_thumbnails_",
|
||||
"CACHE_REDIS_HOST": REDIS_HOST,
|
||||
|
||||
Reference in New Issue
Block a user