From 47bebf963861947eef0e861fd16688072261b591 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Wed, 9 Aug 2017 16:45:08 +0100 Subject: [PATCH] no need to support optional keys.projectState --- .../app/coffee/RedisManager.coffee | 20 ++++++++----------- .../config/settings.defaults.coffee | 2 ++ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/services/document-updater/app/coffee/RedisManager.coffee b/services/document-updater/app/coffee/RedisManager.coffee index b3e6132e4e..718eb1f5b8 100644 --- a/services/document-updater/app/coffee/RedisManager.coffee +++ b/services/document-updater/app/coffee/RedisManager.coffee @@ -90,21 +90,17 @@ module.exports = RedisManager = return callback(error) if error? multi = rclient.multi() multi.srem keys.docsInProject(project_id:project_id), doc_id - if keys.projectState? - multi.del keys.projectState(project_id:project_id) + multi.del keys.projectState(project_id:project_id) multi.exec callback checkOrSetProjectState: (project_id, newState, callback = (error, stateChanged) ->) -> - if keys.projectState? - multi = rclient.multi() - multi.getset keys.projectState(project_id:project_id), newState - multi.expire keys.projectState(project_id:project_id), 30 * minutes - multi.exec (error, response) -> - return callback(error) if error? - logger.log project_id: project_id, newState:newState, oldState: response[0], "checking project state" - callback(null, response[0] isnt newState) - else - callback(null,true) + multi = rclient.multi() + multi.getset keys.projectState(project_id:project_id), newState + multi.expire keys.projectState(project_id:project_id), 30 * minutes + multi.exec (error, response) -> + return callback(error) if error? + logger.log project_id: project_id, newState:newState, oldState: response[0], "checking project state" + callback(null, response[0] isnt newState) getDoc : (project_id, doc_id, callback = (error, lines, version, ranges) ->)-> timer = new metrics.Timer("redis.get-doc") diff --git a/services/document-updater/config/settings.defaults.coffee b/services/document-updater/config/settings.defaults.coffee index b06b9d8bf9..838ffa19a8 100755 --- a/services/document-updater/config/settings.defaults.coffee +++ b/services/document-updater/config/settings.defaults.coffee @@ -41,6 +41,7 @@ module.exports = projectKey: ({doc_id}) -> "ProjectId:#{doc_id}" docsInProject: ({project_id}) -> "DocsIn:#{project_id}" ranges: ({doc_id}) -> "Ranges:#{doc_id}" + projectState: ({project_id}) -> "ProjectState:#{project_id}" # cluster: [{ # port: "7000" # host: "localhost" @@ -54,6 +55,7 @@ module.exports = # projectKey: ({doc_id}) -> "ProjectId:{#{doc_id}}" # docsInProject: ({project_id}) -> "DocsIn:{#{project_id}}" # ranges: ({doc_id}) -> "Ranges:{#{doc_id}}" + # projectState: ({project_id}) -> "ProjectState:{#{project_id}}" history: port:"6379" host:"localhost"