robdiciuccio commented on a change in pull request #11499:
URL: 
https://github.com/apache/incubator-superset/pull/11499#discussion_r537937465



##########
File path: superset/common/query_context.py
##########
@@ -201,7 +232,18 @@ def cache_timeout(self) -> int:
             return self.datasource.database.cache_timeout
         return config["CACHE_DEFAULT_TIMEOUT"]
 
-    def cache_key(self, query_obj: QueryObject, **kwargs: Any) -> 
Optional[str]:
+    def cache_key(self, **extra: Any) -> str:
+        """
+        The cache key is made out of the key/values from self.cached_values, 
plus any
+        other key/values in `extra`
+        """
+        key_prefix = "qc-"
+        cache_dict = self.cache_values.copy()
+        cache_dict.update(extra)
+
+        return generate_cache_key(cache_dict, key_prefix)

Review comment:
       I looked at this again, and what's being cached in the `QueryContext` 
object should be as close to the original `form_data` passed in from the 
client, as that's what's being reinstantiated 
[here](https://github.com/apache/incubator-superset/blob/a8607c046e8abed780a8324af555c1c4de3aaeda/superset/charts/api.py#L616).
 So, caching only the `QueryObject` cache keys (for example) won't work here 
because we ultimately need to rehydrate a `QueryContext` object in order to 
fetch the underlying query data.




----------------------------------------------------------------
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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to