You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@superset.apache.org by GitBox <gi...@apache.org> on 2018/02/16 01:59:34 UTC

[GitHub] mistercrunch commented on a change in pull request #4421: Update core.py

mistercrunch commented on a change in pull request #4421: Update core.py
URL: https://github.com/apache/incubator-superset/pull/4421#discussion_r168661191
 
 

 ##########
 File path: superset/views/core.py
 ##########
 @@ -1275,13 +1276,44 @@ def filter(self, datasource_type, datasource_id, column):
             return json_error_response(DATASOURCE_MISSING_ERR)
         if not self.datasource_access(datasource):
             return json_error_response(DATASOURCE_ACCESS_ERR)
-
-        payload = json.dumps(
-            datasource.values_for_column(
-                column,
-                config.get('FILTER_SELECT_ROW_LIMIT', 10000),
-            ),
-            default=utils.json_int_dttm_ser)
+        # Implement: Cache endpoint by datasource and column
+        cache_key = hashlib.md5((datasource_id + column).encode('utf-8')).hexdigest()
+        if cache_key and cache:
+            if (hasattr(datasource, 'database') and datasource.database.cache_timeout):
+                cache_timeout = datasource.database.cache_timeout
+            elif (hasattr(datasource, 'database') and datasource.cache_timeout):
+                cache_timeout = datasource.database.cache_timeout
+            else:
+                cache_timeout = config.get('CACHE_DEFAULT_TIMEOUT')
+            cache_value = cache.get(cache_key)
+            if cache_value:
 
 Review comment:
   Agreed, I like the idea of caching the filters autocomplete, but we need to refactor some of the caching logic in a single place.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services