{"action":"created","comment":{"url":"https://api.github.com/repos/RackHD/on-core/pulls/comments/48079061","id":48079061,"diff_hunk":"@@ -71,9 +71,64 @@ function lookupServiceFactory(\n      * @constructor\n      */\n     function LookupService () {\n+      this.resetNodeIdCache();\n     }\n \n     /**\n+     * Reset all cached Node IDs.\n+     */\n+    LookupService.prototype.resetNodeIdCache = function () {\n+        this.nodeIdCache = {};\n+    };\n+\n+    /**\n+     * Reset the cache for a specific IP or MAC address.\n+     * @param  {String} cache key - IP or MAC address.\n+     */\n+    LookupService.prototype.clearNodeIdCache = function (key) {\n+        this.nodeIdCache[key] = null;\n+    };\n+\n+    /**\n+     * Check the cache for a Node ID by IP or MAC addres.\n+     * @param  {String} cache key - IP or MAC address.\n+     * @return {Promise|null} Returns a promise if the Node ID is cached,\n+                              otherwise null.\n+     */\n+    LookupService.prototype.checkNodeIdCache = function (key) {\n+      if (typeof this.nodeIdCache[key] === 'string') {\n+          return Promise.resolve(this.nodeIdCache[key]);\n+      }\n+\n+      if (Array.isArray(this.nodeIdCache[key])) {\n+          return new Promise(function (resolve, reject) {","path":"lib/services/lookup.js","position":34,"original_position":34,"commit_id":"d2c8ac822246f1bee8391e02e78effc716e46f90","original_commit_id":"d2c8ac822246f1bee8391e02e78effc716e46f90","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"'reject' is defined but never used.","created_at":"2015-12-18T22:54:04Z","updated_at":"2015-12-18T22:54:04Z","html_url":"https://github.com/RackHD/on-core/pull/49#discussion_r48079061","pull_request_url":"https://api.github.com/repos/RackHD/on-core/pulls/49","_links":{"self":{"href":"https://api.github.com/repos/RackHD/on-core/pulls/comments/48079061"},"html":{"href":"https://github.com/RackHD/on-core/pull/49#discussion_r48079061"},"pull_request":{"href":"https://api.github.com/repos/RackHD/on-core/pulls/49"}}},"pull_request":{"url":"https://api.github.com/repos/RackHD/on-core/pulls/49","id":54159240,"html_url":"https://github.com/RackHD/on-core/pull/49","diff_url":"https://github.com/RackHD/on-core/pull/49.diff","patch_url":"https://github.com/RackHD/on-core/pull/49.patch","issue_url":"https://api.github.com/repos/RackHD/on-core/issues/49","number":49,"state":"open","locked":false,"title":"Adds node ID caching layer to lookup service.","user":{"login":"rolandpoulter","id":51327,"avatar_url":"https://avatars.githubusercontent.com/u/51327?v=3","gravatar_id":"","url":"https://api.github.com/users/rolandpoulter","html_url":"https://github.com/rolandpoulter","followers_url":"https://api.github.com/users/rolandpoulter/followers","following_url":"https://api.github.com/users/rolandpoulter/following{/other_user}","gists_url":"https://api.github.com/users/rolandpoulter/gists{/gist_id}","starred_url":"https://api.github.com/users/rolandpoulter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rolandpoulter/subscriptions","organizations_url":"https://api.github.com/users/rolandpoulter/orgs","repos_url":"https://api.github.com/users/rolandpoulter/repos","events_url":"https://api.github.com/users/rolandpoulter/events{/privacy}","received_events_url":"https://api.github.com/users/rolandpoulter/received_events","type":"User","site_admin":false},"body":"https://groups.google.com/forum/#!topic/rackhd/CiRQhVdkE38\r\n\r\nAttempting to improve logging performance by introducing caching to lookup-service. First cache miss results in a DB query, subsequent cache lookups for the same IP or MAC address will wait for the first query to respond unless the there is already a valid entry in the cache.\r\n\r\nThis should greatly reduce number DB queries by the LookupService.","created_at":"2015-12-18T22:54:01Z","updated_at":"2015-12-18T22:54:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"096752844b1d8838b02e401006c97b6ebb4d5c1f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/RackHD/on-core/pulls/49/commits","review_comments_url":"https://api.github.com/repos/RackHD/on-core/pulls/49/comments","review_comment_url":"https://api.github.com/repos/RackHD/on-core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/RackHD/on-core/issues/49/comments","statuses_url":"https://api.github.com/repos/RackHD/on-core/statuses/d2c8ac822246f1bee8391e02e78effc716e46f90","head":{"label":"rolandpoulter:lookup-service-cache","ref":"lookup-service-cache","sha":"d2c8ac822246f1bee8391e02e78effc716e46f90","user":{"login":"rolandpoulter","id":51327,"avatar_url":"https://avatars.githubusercontent.com/u/51327?v=3","gravatar_id":"","url":"https://api.github.com/users/rolandpoulter","html_url":"https://github.com/rolandpoulter","followers_url":"https://api.github.com/users/rolandpoulter/followers","following_url":"https://api.github.com/users/rolandpoulter/following{/other_user}","gists_url":"https://api.github.com/users/rolandpoulter/gists{/gist_id}","starred_url":"https://api.github.com/users/rolandpoulter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rolandpoulter/subscriptions","organizations_url":"https://api.github.com/users/rolandpoulter/orgs","repos_url":"https://api.github.com/users/rolandpoulter/repos","events_url":"https://api.github.com/users/rolandpoulter/events{/privacy}","received_events_url":"https://api.github.com/users/rolandpoulter/received_events","type":"User","site_admin":false},"repo":{"id":45706376,"name":"on-core","full_name":"rolandpoulter/on-core","owner":{"login":"rolandpoulter","id":51327,"avatar_url":"https://avatars.githubusercontent.com/u/51327?v=3","gravatar_id":"","url":"https://api.github.com/users/rolandpoulter","html_url":"https://github.com/rolandpoulter","followers_url":"https://api.github.com/users/rolandpoulter/followers","following_url":"https://api.github.com/users/rolandpoulter/following{/other_user}","gists_url":"https://api.github.com/users/rolandpoulter/gists{/gist_id}","starred_url":"https://api.github.com/users/rolandpoulter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rolandpoulter/subscriptions","organizations_url":"https://api.github.com/users/rolandpoulter/orgs","repos_url":"https://api.github.com/users/rolandpoulter/repos","events_url":"https://api.github.com/users/rolandpoulter/events{/privacy}","received_events_url":"https://api.github.com/users/rolandpoulter/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rolandpoulter/on-core","description":"","fork":true,"url":"https://api.github.com/repos/rolandpoulter/on-core","forks_url":"https://api.github.com/repos/rolandpoulter/on-core/forks","keys_url":"https://api.github.com/repos/rolandpoulter/on-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rolandpoulter/on-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rolandpoulter/on-core/teams","hooks_url":"https://api.github.com/repos/rolandpoulter/on-core/hooks","issue_events_url":"https://api.github.com/repos/rolandpoulter/on-core/issues/events{/number}","events_url":"https://api.github.com/repos/rolandpoulter/on-core/events","assignees_url":"https://api.github.com/repos/rolandpoulter/on-core/assignees{/user}","branches_url":"https://api.github.com/repos/rolandpoulter/on-core/branches{/branch}","tags_url":"https://api.github.com/repos/rolandpoulter/on-core/tags","blobs_url":"https://api.github.com/repos/rolandpoulter/on-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rolandpoulter/on-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rolandpoulter/on-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/rolandpoulter/on-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rolandpoulter/on-core/statuses/{sha}","languages_url":"https://api.github.com/repos/rolandpoulter/on-core/languages","stargazers_url":"https://api.github.com/repos/rolandpoulter/on-core/stargazers","contributors_url":"https://api.github.com/repos/rolandpoulter/on-core/contributors","subscribers_url":"https://api.github.com/repos/rolandpoulter/on-core/subscribers","subscription_url":"https://api.github.com/repos/rolandpoulter/on-core/subscription","commits_url":"https://api.github.com/repos/rolandpoulter/on-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/rolandpoulter/on-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/rolandpoulter/on-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/rolandpoulter/on-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/rolandpoulter/on-core/contents/{+path}","compare_url":"https://api.github.com/repos/rolandpoulter/on-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rolandpoulter/on-core/merges","archive_url":"https://api.github.com/repos/rolandpoulter/on-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rolandpoulter/on-core/downloads","issues_url":"https://api.github.com/repos/rolandpoulter/on-core/issues{/number}","pulls_url":"https://api.github.com/repos/rolandpoulter/on-core/pulls{/number}","milestones_url":"https://api.github.com/repos/rolandpoulter/on-core/milestones{/number}","notifications_url":"https://api.github.com/repos/rolandpoulter/on-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rolandpoulter/on-core/labels{/name}","releases_url":"https://api.github.com/repos/rolandpoulter/on-core/releases{/id}","created_at":"2015-11-06T20:43:27Z","updated_at":"2015-11-06T20:45:05Z","pushed_at":"2015-12-18T22:50:42Z","git_url":"git://github.com/rolandpoulter/on-core.git","ssh_url":"git@github.com:rolandpoulter/on-core.git","clone_url":"https://github.com/rolandpoulter/on-core.git","svn_url":"https://github.com/rolandpoulter/on-core","homepage":null,"size":723,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"RackHD:master","ref":"master","sha":"66e446c68eb0ebf921f7135a27bb2f8add6a00f7","user":{"login":"RackHD","id":13982662,"avatar_url":"https://avatars.githubusercontent.com/u/13982662?v=3","gravatar_id":"","url":"https://api.github.com/users/RackHD","html_url":"https://github.com/RackHD","followers_url":"https://api.github.com/users/RackHD/followers","following_url":"https://api.github.com/users/RackHD/following{/other_user}","gists_url":"https://api.github.com/users/RackHD/gists{/gist_id}","starred_url":"https://api.github.com/users/RackHD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RackHD/subscriptions","organizations_url":"https://api.github.com/users/RackHD/orgs","repos_url":"https://api.github.com/users/RackHD/repos","events_url":"https://api.github.com/users/RackHD/events{/privacy}","received_events_url":"https://api.github.com/users/RackHD/received_events","type":"Organization","site_admin":false},"repo":{"id":41690044,"name":"on-core","full_name":"RackHD/on-core","owner":{"login":"RackHD","id":13982662,"avatar_url":"https://avatars.githubusercontent.com/u/13982662?v=3","gravatar_id":"","url":"https://api.github.com/users/RackHD","html_url":"https://github.com/RackHD","followers_url":"https://api.github.com/users/RackHD/followers","following_url":"https://api.github.com/users/RackHD/following{/other_user}","gists_url":"https://api.github.com/users/RackHD/gists{/gist_id}","starred_url":"https://api.github.com/users/RackHD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RackHD/subscriptions","organizations_url":"https://api.github.com/users/RackHD/orgs","repos_url":"https://api.github.com/users/RackHD/repos","events_url":"https://api.github.com/users/RackHD/events{/privacy}","received_events_url":"https://api.github.com/users/RackHD/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/RackHD/on-core","description":"","fork":false,"url":"https://api.github.com/repos/RackHD/on-core","forks_url":"https://api.github.com/repos/RackHD/on-core/forks","keys_url":"https://api.github.com/repos/RackHD/on-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/RackHD/on-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/RackHD/on-core/teams","hooks_url":"https://api.github.com/repos/RackHD/on-core/hooks","issue_events_url":"https://api.github.com/repos/RackHD/on-core/issues/events{/number}","events_url":"https://api.github.com/repos/RackHD/on-core/events","assignees_url":"https://api.github.com/repos/RackHD/on-core/assignees{/user}","branches_url":"https://api.github.com/repos/RackHD/on-core/branches{/branch}","tags_url":"https://api.github.com/repos/RackHD/on-core/tags","blobs_url":"https://api.github.com/repos/RackHD/on-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/RackHD/on-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/RackHD/on-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/RackHD/on-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/RackHD/on-core/statuses/{sha}","languages_url":"https://api.github.com/repos/RackHD/on-core/languages","stargazers_url":"https://api.github.com/repos/RackHD/on-core/stargazers","contributors_url":"https://api.github.com/repos/RackHD/on-core/contributors","subscribers_url":"https://api.github.com/repos/RackHD/on-core/subscribers","subscription_url":"https://api.github.com/repos/RackHD/on-core/subscription","commits_url":"https://api.github.com/repos/RackHD/on-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/RackHD/on-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/RackHD/on-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/RackHD/on-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/RackHD/on-core/contents/{+path}","compare_url":"https://api.github.com/repos/RackHD/on-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/RackHD/on-core/merges","archive_url":"https://api.github.com/repos/RackHD/on-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/RackHD/on-core/downloads","issues_url":"https://api.github.com/repos/RackHD/on-core/issues{/number}","pulls_url":"https://api.github.com/repos/RackHD/on-core/pulls{/number}","milestones_url":"https://api.github.com/repos/RackHD/on-core/milestones{/number}","notifications_url":"https://api.github.com/repos/RackHD/on-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/RackHD/on-core/labels{/name}","releases_url":"https://api.github.com/repos/RackHD/on-core/releases{/id}","created_at":"2015-08-31T17:28:32Z","updated_at":"2015-12-08T20:01:53Z","pushed_at":"2015-12-18T22:54:01Z","git_url":"git://github.com/RackHD/on-core.git","ssh_url":"git@github.com:RackHD/on-core.git","clone_url":"https://github.com/RackHD/on-core.git","svn_url":"https://github.com/RackHD/on-core","homepage":null,"size":731,"stargazers_count":6,"watchers_count":6,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":19,"mirror_url":null,"open_issues_count":2,"forks":19,"open_issues":2,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/RackHD/on-core/pulls/49"},"html":{"href":"https://github.com/RackHD/on-core/pull/49"},"issue":{"href":"https://api.github.com/repos/RackHD/on-core/issues/49"},"comments":{"href":"https://api.github.com/repos/RackHD/on-core/issues/49/comments"},"review_comments":{"href":"https://api.github.com/repos/RackHD/on-core/pulls/49/comments"},"review_comment":{"href":"https://api.github.com/repos/RackHD/on-core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/RackHD/on-core/pulls/49/commits"},"statuses":{"href":"https://api.github.com/repos/RackHD/on-core/statuses/d2c8ac822246f1bee8391e02e78effc716e46f90"}}}}