YUKI Hiroshi
null+****@clear*****
Wed Nov 19 18:13:47 JST 2014
YUKI Hiroshi 2014-11-19 18:13:47 +0900 (Wed, 19 Nov 2014) New Revision: 7bb336f30cea41b02d6ce3747c4f9bf73cd91f6d https://github.com/droonga/droonga-http-server/commit/7bb336f30cea41b02d6ce3747c4f9bf73cd91f6d Message: Make TTL of cache entries configurable Modified files: bin/droonga-http-server lib/default-configs.js lib/server-options.js Modified: bin/droonga-http-server (+6 -4) =================================================================== --- bin/droonga-http-server 2014-11-19 18:03:02 +0900 (d414839) +++ bin/droonga-http-server 2014-11-19 18:13:47 +0900 (d832fd5) @@ -106,17 +106,19 @@ if (options.cacheSize > 0) { '/d/select' // Groonga's "select" ]; var cacheMiddlewareRules = [ - { regex: new RegExp('^(' + cachableEndpoints.join('|') + ')') } - // { regex: /^\// } + { regex: new RegExp('^(' + cachableEndpoints.join('|') + ')'), + ttlInSeconds: options.cacheTtlInSeconds } + // { regex: /^\//, + // ttlInSeconds: options.cacheTtlInSeconds } ]; if (droonga.Cache) { var cache = new droonga.Cache({ - size: options.cacheSize, + size: options.cacheSize }); application.use('/statistics/cache', droonga.middleware.cacheStatistics(cache)); application.use(droonga.middleware.cache(cache, { - rules: cacheMiddlewareRules, + rules: cacheMiddlewareRules, logger: logger })); } Modified: lib/default-configs.js (+1 -0) =================================================================== --- lib/default-configs.js 2014-11-19 18:03:02 +0900 (094922e) +++ lib/default-configs.js 2014-11-19 18:13:47 +0900 (bb98367) @@ -58,6 +58,7 @@ function defineDefaultConfigs(configs) { define(configs, 'host', '0.0.0.0'); define(configs, 'port', 10041); define(configs, 'cache_size', 100); + define(configs, 'cache_ttl_in_seconds', 60); define(configs, 'enable_trust_proxy', false); define(configs, 'plugins', [ droonga.API_REST, Modified: lib/server-options.js (+6 -1) =================================================================== --- lib/server-options.js 2014-11-19 18:03:02 +0900 (292b391) +++ lib/server-options.js 2014-11-19 18:13:47 +0900 (bd98518) @@ -12,6 +12,7 @@ options.systemLogLevel = defaultConfigs.system_log_level; options.daemon = defaultConfigs.daemon; options.pidFile = defaultConfigs.pid_file options.cacheSize = defaultConfigs.cache_size; +options.cacheTtlInSeconds = defaultConfigs.cache_ttl_in_seconds; options.enableTrustProxy = defaultConfigs.enable_trust_proxy; options.plugins = defaultConfigs.plugins; options.environment = defaultConfigs.environment; @@ -78,9 +79,13 @@ function define() { '[silly,debug,verbose,info|warn,error]' + '(' + options.systemLogLevel + ')'); add('--cache-size <size>', - 'The max number of cached requests ' + + 'The maximum number of cached responses ' + '(' + options.cacheSize + ')', optionUtils.intOption); + add('--cache-ttl-in-seconds <seconds>', + 'The time to live of cached responses ' + + '(' + options.cacheTtlInSeconds + ')', + optionUtils.intOption); add('--enable-trust-proxy', 'Enable "trust proxy" configuration. It is required when you run droonga-http-server behind a reverse proxy. ' + '(' + options.enableTrustProxy + ')'); -------------- next part -------------- HTML����������������������������...ダウンロード