Sfoglia il codice sorgente

[core] Introduced CACHEABLE_TTL desktop configuration for the Assist/Autocomplete cache TTL

Enrico Berti 9 anni fa
parent
commit
9aebb854af

+ 4 - 0
desktop/conf.dist/hue.ini

@@ -215,6 +215,10 @@
     # e.g. WARNING: You are required to have authorization before you proceed
     ## login_splash_html=
 
+    # Cache timeout in milliseconds for the assist, autocomplete, etc.
+    # defaults to 86400000 (1 day), set to 0 to disable caching
+    ## cacheable_ttl=
+
   # Configuration options for user authentication into the web application
   # ------------------------------------------------------------------------
   [[auth]]

+ 4 - 0
desktop/conf/pseudo-distributed.ini.tmpl

@@ -219,6 +219,10 @@
     # e.g. WARNING: You are required to have authorization before you proceed
     ## login_splash_html=
 
+    # Cache timeout in milliseconds for the assist, autocomplete, etc.
+    # defaults to 86400000 (1 day), set to 0 to disable caching
+    ## cacheable_ttl=
+
   # Configuration options for user authentication into the web application
   # ------------------------------------------------------------------------
   [[auth]]

+ 4 - 0
desktop/core/src/desktop/conf.py

@@ -630,6 +630,10 @@ CUSTOM = ConfigSection(
                    default="",
                    help=_("The login splash HTML code. This code will be placed in the login page, "
                         "useful for security warning messages.")),
+    CACHEABLE_TTL=Config("cacheable_ttl",
+                   default=86400000,
+                   type=int,
+                   help=_("The cache TTL in milliseconds for the assist/autocomplete/etc calls. Set to 0 it disables the cache.")),
 ))
 
 AUTH = ConfigSection(

+ 1 - 1
desktop/core/src/desktop/static/desktop/js/assist/assistHelper.js

@@ -22,7 +22,7 @@
   }
 }(this, function (ko) {
 
-  var TIME_TO_LIVE_IN_MILLIS = $.totalStorage('hue.cacheable.ttl') || 86400000; // 1 day by default, configurable with $.totalStorage('hue.cacheable.ttl', 1234567890)
+  var TIME_TO_LIVE_IN_MILLIS = $.totalStorage('hue.cacheable.ttl.override') || $.totalStorage('hue.cacheable.ttl'); // 1 day by default, configurable with desktop.custom.cacheable_ttl in the .ini or $.totalStorage('hue.cacheable.ttl.override', 1234567890)
   var AUTOCOMPLETE_API_PREFIX = "/notebook/api/autocomplete/";
   var HDFS_API_PREFIX = "/filebrowser/view=";
   var HDFS_PARAMETERS = "?pagesize=100&format=json";

+ 3 - 0
desktop/core/src/desktop/templates/common_header.mako

@@ -208,6 +208,9 @@ from django.utils.translation import ugettext as _
 
     $.fn.dataTableExt.sErrMode = "throw";
 
+    // sets global assistHelper TTL
+    $.totalStorage('hue.cacheable.ttl', ${conf.CUSTOM.CACHEABLE_TTL.get()});
+
     $(document).ready(function () {
       // forces IE's ajax calls not to cache
       if ($.browser.msie) {