feat(key-value): add superset metastore cache#19232
Conversation
0f76444 to
a835e9c
Compare
7c2d53d to
d4338b9
Compare
| with freeze_time(dttm): | ||
| cache.set(FIRST_KEY, FIRST_KEY_INITIAL_VALUE, int(delta.total_seconds())) | ||
| assert cache.get(FIRST_KEY) == FIRST_KEY_INITIAL_VALUE | ||
| with freeze_time(dttm + delta - timedelta(seconds=1)): | ||
| assert cache.has(FIRST_KEY) | ||
| assert cache.get(FIRST_KEY) == FIRST_KEY_INITIAL_VALUE | ||
| with freeze_time(dttm + delta + timedelta(seconds=1)): | ||
| assert cache.has(FIRST_KEY) is False | ||
| assert cache.get(FIRST_KEY) is None |
There was a problem hiding this comment.
Btw I truly LOVE freeze_time! ❤️
Codecov Report
@@ Coverage Diff @@
## master #19232 +/- ##
==========================================
+ Coverage 66.53% 66.59% +0.05%
==========================================
Files 1667 1670 +3
Lines 64360 64501 +141
Branches 6493 6493
==========================================
+ Hits 42824 42952 +128
- Misses 19854 19867 +13
Partials 1682 1682
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
|
/testenv up |
|
@villebro Ephemeral environment spinning up at http://35.87.132.23:8080. Credentials are |
|
I can confirm that the dashboard and explore ephemeral env now work as intended by defaulting to the new cache |
ktmud
left a comment
There was a problem hiding this comment.
Nice work! I'm still a little hesitant on conflating caching and persistent storage (the semantics are just so different), but this does seem to be an improvement to status quo, so I'll vote yes on this change.
| from superset.key_value.types import KeyType | ||
|
|
||
| RESOURCE = "superset_cache" | ||
| KEY_TYPE: KeyType = "uuid" |
There was a problem hiding this comment.
Linking my previous comment about KeyType in case you missed it: #19078 (comment)
There was a problem hiding this comment.
Thanks - many good comments there - I'll be opening a follow-up PR to address those!
|
@ktmud I believe I've addressed all your comments |
michael-s-molina
left a comment
There was a problem hiding this comment.
LGTM. Thanks for the improvement!
|
Ephemeral environment shutdown and build artifacts deleted. |
(cherry picked from commit 72b9a7f)
SUMMARY
Add custom
Flask-Cachingbackend that leverages the newkey_valuetable that was introduced in #19078. This makes it possible to use the metadata database as a cache. Superset defaults to the new cache for required caches that have not been defined in the configs. This is to reintroduce support for multi-pod deployments that don't have a dedicated cache.The cache implements all cache methods that are used in the application (
add,set,get,has,delete), and can be used as a caching backend for any purpose. For instance, to use it to store chart data, the following can be added tosuperset_config.py:In addition, Explore form data/Dashboard filter state caches in the ephemeral environments are currently failing on master - after this gets merged they should now work as intended, as they'll use this cache.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION