-
Notifications
You must be signed in to change notification settings - Fork 148
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
[Spike] Use Flask-Caching for shared caching - prototype 1 #116
Conversation
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.
Looks really good I think 👍
I've thought some more about exactly what/where the user should set stuff and made some suggestions to swap things round a bit - would be great if you could give it a quick try and hopefully it still works fine. Other than that it would be nice to tidy up the data manager up a bit in preparation to discuss with @petar-qb tomorrow by removing the commented out code 🙂
@@ -21,12 +25,15 @@ class DataManager: | |||
|
|||
""" | |||
|
|||
_cache = Cache(config={"CACHE_TYPE": "NullCache"}) |
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.
Note to myself to think about whether we want NullCache
or SimpleCache
as default and whether we want some sort of development vs. production mode that switches cache automatically or gives a hint...
vizro-core/src/vizro/_vizro.py
Outdated
@@ -44,10 +44,13 @@ def build(self, dashboard: Dashboard): | |||
Returns: | |||
Vizro: App object | |||
""" | |||
data_manager._cache.init_app(self.dash.server, config=data_manager._cache.config) |
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.
data_manager._cache.init_app(self.dash.server, config=data_manager._cache.config) | |
data_manager._cache.init_app(self.dash.server) |
I guess that doesn't work?
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.
Remove config=data_manager._cache.config
from here, as it's duplicate
component_data = self._get_original_data(dataset_name) | ||
|
||
# clean up original data if the cache type is not NullCache | ||
self._clean_original_data() |
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.
Why do we want this here and called again in the Vizro.build
? 🤔
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.
Great catch! I now dropped the one in Vizro.build as it's duplicate. We need to put it here so it can prune the original data in two cases:
- when the dashboard first build
- when the cache is invalid, and a reload happens
Superseded by #398. |
Description
New features
Test cases:
to run with redis:
then use
Vizro._cache_config = {"CACHE_TYPE": "RedisCache", "CACHE_REDIS_URL": "redis://localhost:6379/0", "CACHE_DEFAULT_TIMEOUT": 3000,}
to run with gunicorn:
TODOs:
Screenshot
Checklist
Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))
(if applicable)Types of changes
Notice
I acknowledge and agree that, by checking this box and clicking "Submit Pull Request":