You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/06/18 20:57:17 UTC

[GitHub] [superset] shawnzhu commented on issue #15258: documented data cache config doesn't work with flask-caching v1.9.0

shawnzhu commented on issue #15258:
URL: https://github.com/apache/superset/issues/15258#issuecomment-864112590


   I've tried below config stanza with flask-caching 1.9.0 directly and it could reproduce a similar stacktrack:
   
   ```
   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',
   }
   ```
   
   ```Python
   >>> from flask import Flask
   Cache
   
   app = Flask(__name__)>>> from flask_caching import Cache
   >>> 
   >>> app = Flask(__name__)
   >>> import superset_config
   >>> cache = Cache(app, config=superset_config.DATA_CACHE_CONFIG)
   >>> cache.get('foo')
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
     File "/usr/local/lib/python3.7/site-packages/flask_caching/__init__.py", line 248, in get
       return self.cache.get(*args, **kwargs)
     File "/usr/local/lib/python3.7/site-packages/flask_caching/backends/rediscache.py", line 114, in get
       self._read_clients.get(self._get_prefix() + key)
   AttributeError: 'Flask' object has no attribute 'get'
   ```
   
   However, the same code works with Flask-caching 1.10.1. So I dig more then realized the config attribute `CACHE_REDIS_URL` + `'CACHE_TYPE': 'redis'` is not supported in Flask-Caching until 1.10.0. So the above stacktrace is expected outcome by following this constructor: https://github.com/sh4nks/flask-caching/blob/cb6a7a3d61057b07ebdc7a58359b41257fe0af93/flask_caching/backends/rediscache.py#L42-L68
   
   Where the parameter `host` is actually the Flask app object.
   
   ## Suggested Fix
   
   Upgrade Flask-Caching to 1.10.0 or later


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org