apache / superset

Apache Superset is a Data Visualization and Data Exploration Platform
https://superset.apache.org/
Apache License 2.0
62.71k stars 13.85k forks source link

Cannot get caching to work #13795

Closed paulvanharen closed 2 years ago

paulvanharen commented 3 years ago

I'm adding a Flask-Cache configuration to my superset_config.py file. No matter what I try, the result always remains the same: superset/venv/lib/python3.8/site-packages/flask_caching/__init__.py:201: UserWarning: Flask-Caching: CACHE_TYPE is set to null, caching is effectively disabled.

Please find my config file below. I've tried the three respective configurations independently. Redis is installed and passes the ping / PONG test.

''' DATA_CACHE_CONFIG = { 'CACHE_TYPE': 'redis', 'CACHE_DEFAULT_TIMEOUT': 60 60 24, # 1 day default (in secs) 'CACHE_KEY_PREFIX': 'superset_results', 'CACHE_REDIS_URL': 'redis://localhost:6379/0', }

DATA_CACHE_CONFIG = { 'CACHE_TYPE': 'SimpleCache', 'CACHE_DEFAULT_TIMEOUT': 60 60 24, # 1 day default (in secs) 'CACHE_THRESHOLD': 1000, }

''' DATA_CACHE_CONFIG = { 'CACHE_TYPE': 'FileSystemCache', 'CACHE_DEFAULT_TIMEOUT': 60 60 24, # 1 day default (in secs) 'CACHE_THRESHOLD': 1000, 'CACHE_DIR': '/tmp/flask', 'CACHE_OPTIONS': {'mode' : 770} }

Environment

pip list

Package Version


aiohttp 3.7.4.post0 alembic 1.5.8 amqp 2.6.1 apache-superset 1.0.1 apispec 3.3.2 async-timeout 3.0.1 attrs 20.3.0 Babel 2.9.0 backoff 1.10.0 billiard 3.6.3.0 bleach 3.3.0 Brotli 1.0.9 cachelib 0.1.1 celery 4.4.7 certifi 2020.12.5 cffi 1.14.5 chardet 4.0.0 click 7.1.2 colorama 0.4.4 contextlib2 0.6.0.post1 convertdate 2.3.2 cron-descriptor 1.2.24 croniter 1.0.9 cryptography 3.4.6 decorator 4.4.2 defusedxml 0.7.1 dnspython 2.1.0 email-validator 1.1.2 Flask 1.1.2 Flask-AppBuilder 3.2.1 Flask-Babel 1.0.0 Flask-Caching 1.10.1 Flask-Compress 1.9.0 Flask-JWT-Extended 3.25.1 Flask-Login 0.4.1 Flask-Migrate 2.7.0 Flask-OpenID 1.2.5 Flask-SQLAlchemy 2.5.1 flask-talisman 0.7.0 Flask-WTF 0.14.3 geographiclib 1.50 geopy 2.1.0 gevent 21.1.2 greenlet 1.0.0 gunicorn 20.0.4 holidays 0.10.3 humanize 3.3.0 idna 2.10 isodate 0.6.0 itsdangerous 1.1.0 Jinja2 2.11.3 jsonschema 3.2.0 kombu 4.6.11 korean-lunar-calendar 0.2.1 Mako 1.1.4 Markdown 3.3.4 MarkupSafe 1.1.1 marshmallow 3.10.0 marshmallow-enum 1.5.1 marshmallow-sqlalchemy 0.23.1 msgpack 1.0.2 multidict 5.1.0 natsort 7.1.1 numpy 1.20.1 packaging 20.9 pandas 1.1.5 parsedatetime 2.6 pathlib2 2.3.5 pgsanity 0.2.9 Pillow 8.1.2 pip 21.0.1 pkg-resources 0.0.0 polyline 1.4.0 prison 0.1.3 py 1.10.0 pyarrow 1.0.1 pycparser 2.20 pydruid 0.6.2 PyJWT 1.7.1 PyMeeus 0.5.11 pyparsing 2.4.7 pyrsistent 0.17.3 python-dateutil 2.8.1 python-dotenv 0.15.0 python-editor 1.0.4 python-geohash 0.8.5 python3-openid 3.2.0 pytz 2021.1 PyYAML 5.4.1 redis 3.5.3 requests 2.25.1 retry 0.9.2 selenium 3.141.0 setuptools 54.2.0 simplejson 3.17.2 six 1.15.0 slackclient 2.5.0 SQLAlchemy 1.3.23 SQLAlchemy-Utils 0.36.8 sqlparse 0.3.0 typing-extensions 3.7.4.3 urllib3 1.26.4 vine 1.3.0 webencodings 0.5.1 Werkzeug 1.0.1 WTForms 2.3.3 WTForms-JSON 0.3.3 yarl 1.6.3 zope.event 4.5.0 zope.interface 5.3.0

junlincc commented 3 years ago

@nytai might be able to help 🙏

duynguyenhoang commented 3 years ago

@paulvanharen, basically Superset requires 3 cache configs.

# Default cache for Superset objects
CACHE_CONFIG: CacheConfig = {"CACHE_TYPE": "null"}

# Cache for datasource metadata and query results
DATA_CACHE_CONFIG: CacheConfig = {"CACHE_TYPE": "null"}

THUMBNAIL_CACHE_CONFIG: CacheConfig = {
    "CACHE_TYPE": "null",
    "CACHE_NO_NULL_WARNING": True,
}

Your config does work for DATA_CACHE_CONFIG. But you don't have CACHE_CONFIG so that why you got that Warning. You can either config CACHE_CONFIG or disable warning by adding "CACHE_NO_NULL_WARNING": True, Hope this helps you.