From 5b516c4365df607bd34c29d182c164b6fc8751b3 Mon Sep 17 00:00:00 2001 From: Aruna Herath Date: Tue, 28 Jun 2016 13:27:40 +0530 Subject: [PATCH] DocSzCache size is now configurable --- lib/environment_variables.js | 5 +++++ lib/kadira.js | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/environment_variables.js b/lib/environment_variables.js index 3b658064..8c02d819 100644 --- a/lib/environment_variables.js +++ b/lib/environment_variables.js @@ -83,4 +83,9 @@ Kadira._parseEnv._options = { name: 'proxy', parser: Kadira._parseEnv.parseUrl, }, + // number of items cached for tracking document size + KADIRA_OPTIONS_DOCUMENT_SIZE_CACHE_SIZE: { + name: 'documentSizeCacheSize', + parser: Kadira._parseEnv.parseInt, + }, }; diff --git a/lib/kadira.js b/lib/kadira.js index d12bb453..afc581b7 100644 --- a/lib/kadira.js +++ b/lib/kadira.js @@ -19,7 +19,6 @@ Kadira.models.pubsub = new PubsubModel(); Kadira.models.system = new SystemModel(); Kadira.docSzCache = new DocSzCache(100000, 10); - Kadira.connect = function(appId, appSecret, options) { options = options || {}; options.appId = appId; @@ -32,6 +31,12 @@ Kadira.connect = function(appId, appSecret, options) { options.hostname = options.hostname || hostname; options.proxy = options.proxy || null; + if(options.documentSizeCacheSize) { + Kadira.docSzCache = new DocSzCache(documentSizeCacheSize, 10); + } + + console.log(documentSizeCacheSize); + // remove trailing slash from endpoint url (if any) if(_.last(options.endpoint) === '/') { options.endpoint = options.endpoint.substr(0, options.endpoint.length - 1);