Skip to content

Commit

Permalink
Merge pull request #11 from devgateway/IREXCM-55
Browse files Browse the repository at this point in the history
Irexcm 55
  • Loading branch information
mpostelnicu authored Sep 21, 2023
2 parents 58eb932 + 99896a9 commit fd6929c
Showing 1 changed file with 49 additions and 8 deletions.
57 changes: 49 additions & 8 deletions docker/pythonpath_dev/superset_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

from cachelib.file import FileSystemCache
from celery.schedules import crontab
from superset.superset_typing import CacheConfig
from datetime import timedelta

logger = logging.getLogger()

Expand Down Expand Up @@ -65,19 +67,58 @@ def get_env_variable(var_name: str, default: Optional[str] = None) -> str:
REDIS_PORT = get_env_variable("REDIS_PORT")
REDIS_CELERY_DB = get_env_variable("REDIS_CELERY_DB", "0")
REDIS_RESULTS_DB = get_env_variable("REDIS_RESULTS_DB", "1")
REDIS_DATA_DB = get_env_variable("REDIS_DATA_DB", "2")
REDIS_FILTER_DB = get_env_variable("REDIS_FILTER_DB", "3")
REDIS_EXPLORE_DB = get_env_variable("REDIS_EXPLORE_DB", "4")

RESULTS_BACKEND = FileSystemCache("/app/superset_home/sqllab")

CACHE_CONFIG = {
"CACHE_TYPE": "RedisCache",
"CACHE_DEFAULT_TIMEOUT": 300,
"CACHE_KEY_PREFIX": "superset_",
"CACHE_REDIS_HOST": REDIS_HOST,
"CACHE_REDIS_PORT": REDIS_PORT,
"CACHE_REDIS_DB": REDIS_RESULTS_DB,
# CACHE_CONFIG = {
# "CACHE_TYPE": "RedisCache",
# "CACHE_DEFAULT_TIMEOUT": 300,
# "CACHE_KEY_PREFIX": "superset_",
# "CACHE_REDIS_HOST": REDIS_HOST,
# "CACHE_REDIS_PORT": REDIS_PORT,
# "CACHE_REDIS_DB": REDIS_RESULTS_DB,
# }
# DATA_CACHE_CONFIG = CACHE_CONFIG

CACHE_CONFIG: CacheConfig = {
'CACHE_TYPE': 'RedisCache',
'CACHE_DEFAULT_TIMEOUT': int(timedelta(days=1).total_seconds()),
'CACHE_KEY_PREFIX': 'superset_cache_',
'CACHE_REDIS_HOST': REDIS_HOST,
'CACHE_REDIS_PORT': REDIS_PORT,
'CACHE_REDIS_DB': REDIS_RESULTS_DB
}
DATA_CACHE_CONFIG = CACHE_CONFIG

# Cache for datasource metadata and query results
DATA_CACHE_CONFIG: CacheConfig = {
'CACHE_TYPE': 'RedisCache',
'CACHE_DEFAULT_TIMEOUT': int(timedelta(days=1).total_seconds()),
'CACHE_KEY_PREFIX': 'superset_data_',
'CACHE_REDIS_HOST': REDIS_HOST,
'CACHE_REDIS_PORT': REDIS_PORT,
'CACHE_REDIS_DB': REDIS_DATA_DB
}

FILTER_STATE_CACHE_CONFIG: CacheConfig = {
'CACHE_TYPE': 'RedisCache',
'CACHE_DEFAULT_TIMEOUT': int(timedelta(days=1).total_seconds()),
'CACHE_KEY_PREFIX': 'superset_filter_',
'CACHE_REDIS_HOST': REDIS_HOST,
'CACHE_REDIS_PORT': REDIS_PORT,
'CACHE_REDIS_DB': REDIS_FILTER_DB
}

EXPLORE_FORM_DATA_CACHE_CONFIG: CacheConfig = {
'CACHE_TYPE': 'RedisCache',
'CACHE_DEFAULT_TIMEOUT': int(timedelta(days=1).total_seconds()),
'CACHE_KEY_PREFIX': 'superset_explore_',
'CACHE_REDIS_HOST': REDIS_HOST,
'CACHE_REDIS_PORT': REDIS_PORT,
'CACHE_REDIS_DB': REDIS_EXPLORE_DB
}

class CeleryConfig:
broker_url = f"redis://{REDIS_HOST}:{REDIS_PORT}/{REDIS_CELERY_DB}"
Expand Down

0 comments on commit fd6929c

Please sign in to comment.