fabianmenges commented on a change in pull request #4016: [cache] Using the 
query as the basis of the cache key
URL: 
https://github.com/apache/incubator-superset/pull/4016#discussion_r159750668
 
 

 ##########
 File path: superset/viz.py
 ##########
 @@ -225,44 +224,50 @@ def get_json(self, force=False):
             self.get_payload(force),
             default=utils.json_int_dttm_ser, ignore_nan=True)
 
-    @property
-    def cache_key(self):
-        form_data = self.form_data.copy()
-        merge_extra_filters(form_data)
-        s = str([(k, form_data[k]) for k in sorted(form_data.keys())])
-        return hashlib.md5(s.encode('utf-8')).hexdigest()
+    def cache_key(self, query_obj):
+        """
+        The cache key is the database/query string tuple associated with the
+        object which needs to be fully deterministic.
+        """
+
+        return hashlib.md5(
+            json.dumps((
+                self.datasource.database.database_name,
 
 Review comment:
   I think just using the Database name as part of the cache key can cause 
authorization issues. I think we need to include the superset Datasource unique 
id.
   
   Also the database name can still collide with other database names on a 
different server. 
   
   E.g. I'm authorized to only query a single schema in a Database but data for 
a schema that I don't have access to is cached.
     

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to