From 9ff2c146e09c04bf3236e64239879e5b7591964e Mon Sep 17 00:00:00 2001 From: Chris Brame Date: Fri, 17 May 2019 01:06:34 -0400 Subject: [PATCH] perf(cache): improvements --- app.js | 8 +++----- src/cache/index.js | 1 + src/cache/node-cache.js | 4 ---- src/elasticsearch/rebuildIndexChild.js | 3 +-- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/app.js b/app.js index 7e0b00754..f0e386141 100644 --- a/app.js +++ b/app.js @@ -193,6 +193,8 @@ function launchServer (db) { // return next() // }, function (next) { + var NodeCache = require('./src/cache/node-cache') + global.cache = new NodeCache({ checkperiod: 0 }) var fork = require('child_process').fork var memLimit = nconf.get('memlimit') || '2048' @@ -219,11 +221,7 @@ function launchServer (db) { n.on('message', function (data) { if (data.cache) { - var NodeCache = require('./src/cache/node-cache') - global.cache = new NodeCache({ - data: data.cache.data, - checkperiod: 0 - }) + global.cache.data = data.cache.data } }) diff --git a/src/cache/index.js b/src/cache/index.js index 321898569..b8dd474e6 100644 --- a/src/cache/index.js +++ b/src/cache/index.js @@ -222,6 +222,7 @@ truCache.refreshCache = function (callback) { } ], function (err) { + tickets = null return cb(err) } ) diff --git a/src/cache/node-cache.js b/src/cache/node-cache.js index 25c5c3251..565492eae 100644 --- a/src/cache/node-cache.js +++ b/src/cache/node-cache.js @@ -21,13 +21,9 @@ } var hasProp = {}.hasOwnProperty - var slice = [].slice - _ = require('lodash') - clone = require('clone') - EventEmitter = require('events').EventEmitter module.exports = (function (superClass) { diff --git a/src/elasticsearch/rebuildIndexChild.js b/src/elasticsearch/rebuildIndexChild.js index ce8cebbe3..6cb492487 100644 --- a/src/elasticsearch/rebuildIndexChild.js +++ b/src/elasticsearch/rebuildIndexChild.js @@ -343,7 +343,6 @@ function crawlTickets (callback) { } function rebuild (callback) { - setupClient() async.series( [ function (next) { @@ -363,7 +362,7 @@ function rebuild (callback) { } ], function (err) { - if (err) winston.debug(err) + if (err) winston.error(err) return callback(err) }