{"action":"created","comment":{"url":"https://api.github.com/repos/mcollina/node-coap/pulls/comments/64904127","id":64904127,"diff_hunk":"@@ -305,23 +318,54 @@ CoAPServer.prototype._handle = function(packet, rsinfo) {\n   request.rsinfo = rsinfo\n   response.statusCode = '2.05'\n   response._request = request._packet\n+  response._cachekey = toCacheKey(rsinfo.address, rsinfo.port, packet)\n \n   var block2cache = this._block2Cache;\n+  var block2cache_expiry = this._options.block2CacheExpiryMs;\n   //inject this function so the response can add an entry to the cache\n   response._addCacheEntry = function(key, payload) {\n-    debug('add payload to cache, key:', key);\n-    block2cache.key = key;\n-    block2cache.payload = payload;\n+    if (block2cache.hasOwnProperty(key)) {\n+      debug('delete old cache entry, key:', key)\n+      clearTimeout(block2cache[key].timeoutId)\n+      delete block2cache[key]\n+    }\n+\n+    debug('add payload to cache, key:', key)\n+    block2cache[key] = {'payload': payload}\n+\n+    // setup clean-up timer\n+    block2cache[key].timeoutId = setTimeout(function(k) {\n+      debug('delete expired cache entry, key:', k)\n+      delete block2cache[k]\n+    }, block2cache_expiry, key)","path":"lib/server.js","position":62,"original_position":62,"commit_id":"8a88988ea7e42586fae81e9f78f73b0f2974bd8c","original_commit_id":"8a88988ea7e42586fae81e9f78f73b0f2974bd8c","user":{"login":"mcollina","id":52195,"avatar_url":"https://avatars.githubusercontent.com/u/52195?v=3","gravatar_id":"","url":"https://api.github.com/users/mcollina","html_url":"https://github.com/mcollina","followers_url":"https://api.github.com/users/mcollina/followers","following_url":"https://api.github.com/users/mcollina/following{/other_user}","gists_url":"https://api.github.com/users/mcollina/gists{/gist_id}","starred_url":"https://api.github.com/users/mcollina/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mcollina/subscriptions","organizations_url":"https://api.github.com/users/mcollina/orgs","repos_url":"https://api.github.com/users/mcollina/repos","events_url":"https://api.github.com/users/mcollina/events{/privacy}","received_events_url":"https://api.github.com/users/mcollina/received_events","type":"User","site_admin":false},"body":"I don't understand what this should mean.","created_at":"2016-05-27T13:29:39Z","updated_at":"2016-05-27T13:29:39Z","html_url":"https://github.com/mcollina/node-coap/pull/121#discussion_r64904127","pull_request_url":"https://api.github.com/repos/mcollina/node-coap/pulls/121","_links":{"self":{"href":"https://api.github.com/repos/mcollina/node-coap/pulls/comments/64904127"},"html":{"href":"https://github.com/mcollina/node-coap/pull/121#discussion_r64904127"},"pull_request":{"href":"https://api.github.com/repos/mcollina/node-coap/pulls/121"}}},"pull_request":{"url":"https://api.github.com/repos/mcollina/node-coap/pulls/121","id":71203075,"html_url":"https://github.com/mcollina/node-coap/pull/121","diff_url":"https://github.com/mcollina/node-coap/pull/121.diff","patch_url":"https://github.com/mcollina/node-coap/pull/121.patch","issue_url":"https://api.github.com/repos/mcollina/node-coap/issues/121","number":121,"state":"open","locked":false,"title":"Fix blockwise2 transfer for multiclient use-case; change single-entry block2Cache to multi-entry cache","user":{"login":"jkivilin","id":11323,"avatar_url":"https://avatars.githubusercontent.com/u/11323?v=3","gravatar_id":"","url":"https://api.github.com/users/jkivilin","html_url":"https://github.com/jkivilin","followers_url":"https://api.github.com/users/jkivilin/followers","following_url":"https://api.github.com/users/jkivilin/following{/other_user}","gists_url":"https://api.github.com/users/jkivilin/gists{/gist_id}","starred_url":"https://api.github.com/users/jkivilin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkivilin/subscriptions","organizations_url":"https://api.github.com/users/jkivilin/orgs","repos_url":"https://api.github.com/users/jkivilin/repos","events_url":"https://api.github.com/users/jkivilin/events{/privacy}","received_events_url":"https://api.github.com/users/jkivilin/received_events","type":"User","site_admin":false},"body":"Proposed fix for issue #120 ","created_at":"2016-05-24T11:28:15Z","updated_at":"2016-05-27T13:29:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"139883b6e38444419753169fe0c983e093994ade","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mcollina/node-coap/pulls/121/commits","review_comments_url":"https://api.github.com/repos/mcollina/node-coap/pulls/121/comments","review_comment_url":"https://api.github.com/repos/mcollina/node-coap/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mcollina/node-coap/issues/121/comments","statuses_url":"https://api.github.com/repos/mcollina/node-coap/statuses/8a88988ea7e42586fae81e9f78f73b0f2974bd8c","head":{"label":"jkivilin:fix-for-block2cache","ref":"fix-for-block2cache","sha":"8a88988ea7e42586fae81e9f78f73b0f2974bd8c","user":{"login":"jkivilin","id":11323,"avatar_url":"https://avatars.githubusercontent.com/u/11323?v=3","gravatar_id":"","url":"https://api.github.com/users/jkivilin","html_url":"https://github.com/jkivilin","followers_url":"https://api.github.com/users/jkivilin/followers","following_url":"https://api.github.com/users/jkivilin/following{/other_user}","gists_url":"https://api.github.com/users/jkivilin/gists{/gist_id}","starred_url":"https://api.github.com/users/jkivilin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkivilin/subscriptions","organizations_url":"https://api.github.com/users/jkivilin/orgs","repos_url":"https://api.github.com/users/jkivilin/repos","events_url":"https://api.github.com/users/jkivilin/events{/privacy}","received_events_url":"https://api.github.com/users/jkivilin/received_events","type":"User","site_admin":false},"repo":{"id":59566754,"name":"node-coap","full_name":"jkivilin/node-coap","owner":{"login":"jkivilin","id":11323,"avatar_url":"https://avatars.githubusercontent.com/u/11323?v=3","gravatar_id":"","url":"https://api.github.com/users/jkivilin","html_url":"https://github.com/jkivilin","followers_url":"https://api.github.com/users/jkivilin/followers","following_url":"https://api.github.com/users/jkivilin/following{/other_user}","gists_url":"https://api.github.com/users/jkivilin/gists{/gist_id}","starred_url":"https://api.github.com/users/jkivilin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkivilin/subscriptions","organizations_url":"https://api.github.com/users/jkivilin/orgs","repos_url":"https://api.github.com/users/jkivilin/repos","events_url":"https://api.github.com/users/jkivilin/events{/privacy}","received_events_url":"https://api.github.com/users/jkivilin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jkivilin/node-coap","description":"CoAP - Node.js style","fork":true,"url":"https://api.github.com/repos/jkivilin/node-coap","forks_url":"https://api.github.com/repos/jkivilin/node-coap/forks","keys_url":"https://api.github.com/repos/jkivilin/node-coap/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jkivilin/node-coap/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jkivilin/node-coap/teams","hooks_url":"https://api.github.com/repos/jkivilin/node-coap/hooks","issue_events_url":"https://api.github.com/repos/jkivilin/node-coap/issues/events{/number}","events_url":"https://api.github.com/repos/jkivilin/node-coap/events","assignees_url":"https://api.github.com/repos/jkivilin/node-coap/assignees{/user}","branches_url":"https://api.github.com/repos/jkivilin/node-coap/branches{/branch}","tags_url":"https://api.github.com/repos/jkivilin/node-coap/tags","blobs_url":"https://api.github.com/repos/jkivilin/node-coap/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jkivilin/node-coap/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jkivilin/node-coap/git/refs{/sha}","trees_url":"https://api.github.com/repos/jkivilin/node-coap/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jkivilin/node-coap/statuses/{sha}","languages_url":"https://api.github.com/repos/jkivilin/node-coap/languages","stargazers_url":"https://api.github.com/repos/jkivilin/node-coap/stargazers","contributors_url":"https://api.github.com/repos/jkivilin/node-coap/contributors","subscribers_url":"https://api.github.com/repos/jkivilin/node-coap/subscribers","subscription_url":"https://api.github.com/repos/jkivilin/node-coap/subscription","commits_url":"https://api.github.com/repos/jkivilin/node-coap/commits{/sha}","git_commits_url":"https://api.github.com/repos/jkivilin/node-coap/git/commits{/sha}","comments_url":"https://api.github.com/repos/jkivilin/node-coap/comments{/number}","issue_comment_url":"https://api.github.com/repos/jkivilin/node-coap/issues/comments{/number}","contents_url":"https://api.github.com/repos/jkivilin/node-coap/contents/{+path}","compare_url":"https://api.github.com/repos/jkivilin/node-coap/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jkivilin/node-coap/merges","archive_url":"https://api.github.com/repos/jkivilin/node-coap/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jkivilin/node-coap/downloads","issues_url":"https://api.github.com/repos/jkivilin/node-coap/issues{/number}","pulls_url":"https://api.github.com/repos/jkivilin/node-coap/pulls{/number}","milestones_url":"https://api.github.com/repos/jkivilin/node-coap/milestones{/number}","notifications_url":"https://api.github.com/repos/jkivilin/node-coap/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jkivilin/node-coap/labels{/name}","releases_url":"https://api.github.com/repos/jkivilin/node-coap/releases{/id}","deployments_url":"https://api.github.com/repos/jkivilin/node-coap/deployments","created_at":"2016-05-24T11:20:50Z","updated_at":"2016-05-24T11:20:51Z","pushed_at":"2016-05-27T10:13:05Z","git_url":"git://github.com/jkivilin/node-coap.git","ssh_url":"git@github.com:jkivilin/node-coap.git","clone_url":"https://github.com/jkivilin/node-coap.git","svn_url":"https://github.com/jkivilin/node-coap","homepage":"","size":354,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"mcollina:master","ref":"master","sha":"2c421ff292697f02a41c9edfbff187d106184b47","user":{"login":"mcollina","id":52195,"avatar_url":"https://avatars.githubusercontent.com/u/52195?v=3","gravatar_id":"","url":"https://api.github.com/users/mcollina","html_url":"https://github.com/mcollina","followers_url":"https://api.github.com/users/mcollina/followers","following_url":"https://api.github.com/users/mcollina/following{/other_user}","gists_url":"https://api.github.com/users/mcollina/gists{/gist_id}","starred_url":"https://api.github.com/users/mcollina/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mcollina/subscriptions","organizations_url":"https://api.github.com/users/mcollina/orgs","repos_url":"https://api.github.com/users/mcollina/repos","events_url":"https://api.github.com/users/mcollina/events{/privacy}","received_events_url":"https://api.github.com/users/mcollina/received_events","type":"User","site_admin":false},"repo":{"id":10504120,"name":"node-coap","full_name":"mcollina/node-coap","owner":{"login":"mcollina","id":52195,"avatar_url":"https://avatars.githubusercontent.com/u/52195?v=3","gravatar_id":"","url":"https://api.github.com/users/mcollina","html_url":"https://github.com/mcollina","followers_url":"https://api.github.com/users/mcollina/followers","following_url":"https://api.github.com/users/mcollina/following{/other_user}","gists_url":"https://api.github.com/users/mcollina/gists{/gist_id}","starred_url":"https://api.github.com/users/mcollina/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mcollina/subscriptions","organizations_url":"https://api.github.com/users/mcollina/orgs","repos_url":"https://api.github.com/users/mcollina/repos","events_url":"https://api.github.com/users/mcollina/events{/privacy}","received_events_url":"https://api.github.com/users/mcollina/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mcollina/node-coap","description":"CoAP - Node.js style","fork":false,"url":"https://api.github.com/repos/mcollina/node-coap","forks_url":"https://api.github.com/repos/mcollina/node-coap/forks","keys_url":"https://api.github.com/repos/mcollina/node-coap/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mcollina/node-coap/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mcollina/node-coap/teams","hooks_url":"https://api.github.com/repos/mcollina/node-coap/hooks","issue_events_url":"https://api.github.com/repos/mcollina/node-coap/issues/events{/number}","events_url":"https://api.github.com/repos/mcollina/node-coap/events","assignees_url":"https://api.github.com/repos/mcollina/node-coap/assignees{/user}","branches_url":"https://api.github.com/repos/mcollina/node-coap/branches{/branch}","tags_url":"https://api.github.com/repos/mcollina/node-coap/tags","blobs_url":"https://api.github.com/repos/mcollina/node-coap/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mcollina/node-coap/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mcollina/node-coap/git/refs{/sha}","trees_url":"https://api.github.com/repos/mcollina/node-coap/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mcollina/node-coap/statuses/{sha}","languages_url":"https://api.github.com/repos/mcollina/node-coap/languages","stargazers_url":"https://api.github.com/repos/mcollina/node-coap/stargazers","contributors_url":"https://api.github.com/repos/mcollina/node-coap/contributors","subscribers_url":"https://api.github.com/repos/mcollina/node-coap/subscribers","subscription_url":"https://api.github.com/repos/mcollina/node-coap/subscription","commits_url":"https://api.github.com/repos/mcollina/node-coap/commits{/sha}","git_commits_url":"https://api.github.com/repos/mcollina/node-coap/git/commits{/sha}","comments_url":"https://api.github.com/repos/mcollina/node-coap/comments{/number}","issue_comment_url":"https://api.github.com/repos/mcollina/node-coap/issues/comments{/number}","contents_url":"https://api.github.com/repos/mcollina/node-coap/contents/{+path}","compare_url":"https://api.github.com/repos/mcollina/node-coap/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mcollina/node-coap/merges","archive_url":"https://api.github.com/repos/mcollina/node-coap/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mcollina/node-coap/downloads","issues_url":"https://api.github.com/repos/mcollina/node-coap/issues{/number}","pulls_url":"https://api.github.com/repos/mcollina/node-coap/pulls{/number}","milestones_url":"https://api.github.com/repos/mcollina/node-coap/milestones{/number}","notifications_url":"https://api.github.com/repos/mcollina/node-coap/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mcollina/node-coap/labels{/name}","releases_url":"https://api.github.com/repos/mcollina/node-coap/releases{/id}","deployments_url":"https://api.github.com/repos/mcollina/node-coap/deployments","created_at":"2013-06-05T14:12:39Z","updated_at":"2016-05-27T12:36:30Z","pushed_at":"2016-05-27T12:58:56Z","git_url":"git://github.com/mcollina/node-coap.git","ssh_url":"git@github.com:mcollina/node-coap.git","clone_url":"https://github.com/mcollina/node-coap.git","svn_url":"https://github.com/mcollina/node-coap","homepage":"","size":383,"stargazers_count":177,"watchers_count":177,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":55,"mirror_url":null,"open_issues_count":25,"forks":55,"open_issues":25,"watchers":177,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mcollina/node-coap/pulls/121"},"html":{"href":"https://github.com/mcollina/node-coap/pull/121"},"issue":{"href":"https://api.github.com/repos/mcollina/node-coap/issues/121"},"comments":{"href":"https://api.github.com/repos/mcollina/node-coap/issues/121/comments"},"review_comments":{"href":"https://api.github.com/repos/mcollina/node-coap/pulls/121/comments"},"review_comment":{"href":"https://api.github.com/repos/mcollina/node-coap/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mcollina/node-coap/pulls/121/commits"},"statuses":{"href":"https://api.github.com/repos/mcollina/node-coap/statuses/8a88988ea7e42586fae81e9f78f73b0f2974bd8c"}}}}
{"actor":{"display_login":"mcollina"}}