{"action":"created","comment":{"url":"https://api.github.com/repos/rtomayko/rack-cache/pulls/comments/50503300","id":50503300,"diff_hunk":"@@ -38,13 +38,20 @@ def lookup(request, entity_store)\n       return nil if match.nil?\n \n       _, res = match\n-      if body = entity_store.open(res['X-Content-Digest'])\n-        restore_response(res, body)\n+\n+      if entity_store.nil?\n+        body = ['']\n       else\n-        # TODO the metastore referenced an entity that doesn't exist in\n-        # the entitystore. we definitely want to return nil but we should\n-        # also purge the entry from the meta-store when this is detected.\n+        body = entity_store.open(res['X-Content-Digest'])\n+        if body.nil?\n+          # TODO the metastore referenced an entity that doesn't exist in\n+          # the entitystore. we definitely want to return nil but we should","path":"lib/rack/cache/metastore.rb","position":16,"original_position":16,"commit_id":"8ff25d31303a8069ca4b1c30cdc05771f571aad2","original_commit_id":"8ff25d31303a8069ca4b1c30cdc05771f571aad2","user":{"login":"grosser","id":11367,"avatar_url":"https://avatars.githubusercontent.com/u/11367?v=3","gravatar_id":"","url":"https://api.github.com/users/grosser","html_url":"https://github.com/grosser","followers_url":"https://api.github.com/users/grosser/followers","following_url":"https://api.github.com/users/grosser/following{/other_user}","gists_url":"https://api.github.com/users/grosser/gists{/gist_id}","starred_url":"https://api.github.com/users/grosser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grosser/subscriptions","organizations_url":"https://api.github.com/users/grosser/orgs","repos_url":"https://api.github.com/users/grosser/repos","events_url":"https://api.github.com/users/grosser/events{/privacy}","received_events_url":"https://api.github.com/users/grosser/received_events","type":"User","site_admin":false},"body":"are you worried about bad data in the metastore ?","created_at":"2016-01-22T05:26:36Z","updated_at":"2016-01-22T05:26:36Z","html_url":"https://github.com/rtomayko/rack-cache/pull/129#discussion_r50503300","pull_request_url":"https://api.github.com/repos/rtomayko/rack-cache/pulls/129","_links":{"self":{"href":"https://api.github.com/repos/rtomayko/rack-cache/pulls/comments/50503300"},"html":{"href":"https://github.com/rtomayko/rack-cache/pull/129#discussion_r50503300"},"pull_request":{"href":"https://api.github.com/repos/rtomayko/rack-cache/pulls/129"}}},"pull_request":{"url":"https://api.github.com/repos/rtomayko/rack-cache/pulls/129","id":56604624,"html_url":"https://github.com/rtomayko/rack-cache/pull/129","diff_url":"https://github.com/rtomayko/rack-cache/pull/129.diff","patch_url":"https://github.com/rtomayko/rack-cache/pull/129.patch","issue_url":"https://api.github.com/repos/rtomayko/rack-cache/issues/129","number":129,"state":"open","locked":false,"title":"Allow setting the entity store to nil","user":{"login":"amatriain","id":1439986,"avatar_url":"https://avatars.githubusercontent.com/u/1439986?v=3","gravatar_id":"","url":"https://api.github.com/users/amatriain","html_url":"https://github.com/amatriain","followers_url":"https://api.github.com/users/amatriain/followers","following_url":"https://api.github.com/users/amatriain/following{/other_user}","gists_url":"https://api.github.com/users/amatriain/gists{/gist_id}","starred_url":"https://api.github.com/users/amatriain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amatriain/subscriptions","organizations_url":"https://api.github.com/users/amatriain/orgs","repos_url":"https://api.github.com/users/amatriain/repos","events_url":"https://api.github.com/users/amatriain/events{/privacy}","received_events_url":"https://api.github.com/users/amatriain/received_events","type":"User","site_admin":false},"body":"This PR adds the ability to set rack-cache entity store to nil, e.g.:\r\n\r\n```\r\nrequire 'rack/cache'\r\n\r\nuse Rack::Cache,\r\n  :metastore   => 'file:/var/cache/rack/meta',\r\n  :entitystore => nil,\r\n  :verbose     => true\r\n\r\nrun app\r\n```\r\n\r\nWhen ```entitystore``` is set to nil, rack-cache doesn't persist response bodies. If a cached response is still fresh, or if it's stale but found to be still valid, rack-cache returns only the response headers with an empty body. The code performing the request should check if the response comes from the cache (e.g. checking the ```X-Rack-Cache``` header) and in in this case ignore the response body.\r\n\r\nObviously this is only useful for use cases in which, if a cached response is still valid, its body is not interesting.\r\n\r\nThis is useful for my particular use case but may be interesting for other people. In particular this avoids the common problem of the backend (disk in my case) filling up with old entities, because rack-cache performs no cleanup of old useless entities once there is a new response. This can be avoided with this PR by not persisting entries in the backend in the first place.","created_at":"2016-01-20T13:03:17Z","updated_at":"2016-01-22T05:26:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"489fc393d5c18dd8a85142f0fed4a3c69c973b5e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rtomayko/rack-cache/pulls/129/commits","review_comments_url":"https://api.github.com/repos/rtomayko/rack-cache/pulls/129/comments","review_comment_url":"https://api.github.com/repos/rtomayko/rack-cache/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rtomayko/rack-cache/issues/129/comments","statuses_url":"https://api.github.com/repos/rtomayko/rack-cache/statuses/8ff25d31303a8069ca4b1c30cdc05771f571aad2","head":{"label":"amatriain:donotstore-backend","ref":"donotstore-backend","sha":"8ff25d31303a8069ca4b1c30cdc05771f571aad2","user":{"login":"amatriain","id":1439986,"avatar_url":"https://avatars.githubusercontent.com/u/1439986?v=3","gravatar_id":"","url":"https://api.github.com/users/amatriain","html_url":"https://github.com/amatriain","followers_url":"https://api.github.com/users/amatriain/followers","following_url":"https://api.github.com/users/amatriain/following{/other_user}","gists_url":"https://api.github.com/users/amatriain/gists{/gist_id}","starred_url":"https://api.github.com/users/amatriain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amatriain/subscriptions","organizations_url":"https://api.github.com/users/amatriain/orgs","repos_url":"https://api.github.com/users/amatriain/repos","events_url":"https://api.github.com/users/amatriain/events{/privacy}","received_events_url":"https://api.github.com/users/amatriain/received_events","type":"User","site_admin":false},"repo":{"id":29441451,"name":"rack-cache","full_name":"amatriain/rack-cache","owner":{"login":"amatriain","id":1439986,"avatar_url":"https://avatars.githubusercontent.com/u/1439986?v=3","gravatar_id":"","url":"https://api.github.com/users/amatriain","html_url":"https://github.com/amatriain","followers_url":"https://api.github.com/users/amatriain/followers","following_url":"https://api.github.com/users/amatriain/following{/other_user}","gists_url":"https://api.github.com/users/amatriain/gists{/gist_id}","starred_url":"https://api.github.com/users/amatriain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amatriain/subscriptions","organizations_url":"https://api.github.com/users/amatriain/orgs","repos_url":"https://api.github.com/users/amatriain/repos","events_url":"https://api.github.com/users/amatriain/events{/privacy}","received_events_url":"https://api.github.com/users/amatriain/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/amatriain/rack-cache","description":"Real HTTP Caching for Ruby Web Apps","fork":true,"url":"https://api.github.com/repos/amatriain/rack-cache","forks_url":"https://api.github.com/repos/amatriain/rack-cache/forks","keys_url":"https://api.github.com/repos/amatriain/rack-cache/keys{/key_id}","collaborators_url":"https://api.github.com/repos/amatriain/rack-cache/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/amatriain/rack-cache/teams","hooks_url":"https://api.github.com/repos/amatriain/rack-cache/hooks","issue_events_url":"https://api.github.com/repos/amatriain/rack-cache/issues/events{/number}","events_url":"https://api.github.com/repos/amatriain/rack-cache/events","assignees_url":"https://api.github.com/repos/amatriain/rack-cache/assignees{/user}","branches_url":"https://api.github.com/repos/amatriain/rack-cache/branches{/branch}","tags_url":"https://api.github.com/repos/amatriain/rack-cache/tags","blobs_url":"https://api.github.com/repos/amatriain/rack-cache/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/amatriain/rack-cache/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/amatriain/rack-cache/git/refs{/sha}","trees_url":"https://api.github.com/repos/amatriain/rack-cache/git/trees{/sha}","statuses_url":"https://api.github.com/repos/amatriain/rack-cache/statuses/{sha}","languages_url":"https://api.github.com/repos/amatriain/rack-cache/languages","stargazers_url":"https://api.github.com/repos/amatriain/rack-cache/stargazers","contributors_url":"https://api.github.com/repos/amatriain/rack-cache/contributors","subscribers_url":"https://api.github.com/repos/amatriain/rack-cache/subscribers","subscription_url":"https://api.github.com/repos/amatriain/rack-cache/subscription","commits_url":"https://api.github.com/repos/amatriain/rack-cache/commits{/sha}","git_commits_url":"https://api.github.com/repos/amatriain/rack-cache/git/commits{/sha}","comments_url":"https://api.github.com/repos/amatriain/rack-cache/comments{/number}","issue_comment_url":"https://api.github.com/repos/amatriain/rack-cache/issues/comments{/number}","contents_url":"https://api.github.com/repos/amatriain/rack-cache/contents/{+path}","compare_url":"https://api.github.com/repos/amatriain/rack-cache/compare/{base}...{head}","merges_url":"https://api.github.com/repos/amatriain/rack-cache/merges","archive_url":"https://api.github.com/repos/amatriain/rack-cache/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/amatriain/rack-cache/downloads","issues_url":"https://api.github.com/repos/amatriain/rack-cache/issues{/number}","pulls_url":"https://api.github.com/repos/amatriain/rack-cache/pulls{/number}","milestones_url":"https://api.github.com/repos/amatriain/rack-cache/milestones{/number}","notifications_url":"https://api.github.com/repos/amatriain/rack-cache/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/amatriain/rack-cache/labels{/name}","releases_url":"https://api.github.com/repos/amatriain/rack-cache/releases{/id}","deployments_url":"https://api.github.com/repos/amatriain/rack-cache/deployments","created_at":"2015-01-18T21:17:48Z","updated_at":"2016-01-11T12:18:40Z","pushed_at":"2016-01-19T22:25:01Z","git_url":"git://github.com/amatriain/rack-cache.git","ssh_url":"git@github.com:amatriain/rack-cache.git","clone_url":"https://github.com/amatriain/rack-cache.git","svn_url":"https://github.com/amatriain/rack-cache","homepage":"http://rtomayko.github.io/rack-cache/","size":994,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":false,"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":"rtomayko:master","ref":"master","sha":"f96febebed7700337e8c362403b081e45b8e4f13","user":{"login":"rtomayko","id":404,"avatar_url":"https://avatars.githubusercontent.com/u/404?v=3","gravatar_id":"","url":"https://api.github.com/users/rtomayko","html_url":"https://github.com/rtomayko","followers_url":"https://api.github.com/users/rtomayko/followers","following_url":"https://api.github.com/users/rtomayko/following{/other_user}","gists_url":"https://api.github.com/users/rtomayko/gists{/gist_id}","starred_url":"https://api.github.com/users/rtomayko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rtomayko/subscriptions","organizations_url":"https://api.github.com/users/rtomayko/orgs","repos_url":"https://api.github.com/users/rtomayko/repos","events_url":"https://api.github.com/users/rtomayko/events{/privacy}","received_events_url":"https://api.github.com/users/rtomayko/received_events","type":"User","site_admin":true},"repo":{"id":67542,"name":"rack-cache","full_name":"rtomayko/rack-cache","owner":{"login":"rtomayko","id":404,"avatar_url":"https://avatars.githubusercontent.com/u/404?v=3","gravatar_id":"","url":"https://api.github.com/users/rtomayko","html_url":"https://github.com/rtomayko","followers_url":"https://api.github.com/users/rtomayko/followers","following_url":"https://api.github.com/users/rtomayko/following{/other_user}","gists_url":"https://api.github.com/users/rtomayko/gists{/gist_id}","starred_url":"https://api.github.com/users/rtomayko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rtomayko/subscriptions","organizations_url":"https://api.github.com/users/rtomayko/orgs","repos_url":"https://api.github.com/users/rtomayko/repos","events_url":"https://api.github.com/users/rtomayko/events{/privacy}","received_events_url":"https://api.github.com/users/rtomayko/received_events","type":"User","site_admin":true},"private":false,"html_url":"https://github.com/rtomayko/rack-cache","description":"Real HTTP Caching for Ruby Web Apps","fork":false,"url":"https://api.github.com/repos/rtomayko/rack-cache","forks_url":"https://api.github.com/repos/rtomayko/rack-cache/forks","keys_url":"https://api.github.com/repos/rtomayko/rack-cache/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rtomayko/rack-cache/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rtomayko/rack-cache/teams","hooks_url":"https://api.github.com/repos/rtomayko/rack-cache/hooks","issue_events_url":"https://api.github.com/repos/rtomayko/rack-cache/issues/events{/number}","events_url":"https://api.github.com/repos/rtomayko/rack-cache/events","assignees_url":"https://api.github.com/repos/rtomayko/rack-cache/assignees{/user}","branches_url":"https://api.github.com/repos/rtomayko/rack-cache/branches{/branch}","tags_url":"https://api.github.com/repos/rtomayko/rack-cache/tags","blobs_url":"https://api.github.com/repos/rtomayko/rack-cache/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rtomayko/rack-cache/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rtomayko/rack-cache/git/refs{/sha}","trees_url":"https://api.github.com/repos/rtomayko/rack-cache/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rtomayko/rack-cache/statuses/{sha}","languages_url":"https://api.github.com/repos/rtomayko/rack-cache/languages","stargazers_url":"https://api.github.com/repos/rtomayko/rack-cache/stargazers","contributors_url":"https://api.github.com/repos/rtomayko/rack-cache/contributors","subscribers_url":"https://api.github.com/repos/rtomayko/rack-cache/subscribers","subscription_url":"https://api.github.com/repos/rtomayko/rack-cache/subscription","commits_url":"https://api.github.com/repos/rtomayko/rack-cache/commits{/sha}","git_commits_url":"https://api.github.com/repos/rtomayko/rack-cache/git/commits{/sha}","comments_url":"https://api.github.com/repos/rtomayko/rack-cache/comments{/number}","issue_comment_url":"https://api.github.com/repos/rtomayko/rack-cache/issues/comments{/number}","contents_url":"https://api.github.com/repos/rtomayko/rack-cache/contents/{+path}","compare_url":"https://api.github.com/repos/rtomayko/rack-cache/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rtomayko/rack-cache/merges","archive_url":"https://api.github.com/repos/rtomayko/rack-cache/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rtomayko/rack-cache/downloads","issues_url":"https://api.github.com/repos/rtomayko/rack-cache/issues{/number}","pulls_url":"https://api.github.com/repos/rtomayko/rack-cache/pulls{/number}","milestones_url":"https://api.github.com/repos/rtomayko/rack-cache/milestones{/number}","notifications_url":"https://api.github.com/repos/rtomayko/rack-cache/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rtomayko/rack-cache/labels{/name}","releases_url":"https://api.github.com/repos/rtomayko/rack-cache/releases{/id}","deployments_url":"https://api.github.com/repos/rtomayko/rack-cache/deployments","created_at":"2008-10-25T02:02:09Z","updated_at":"2016-01-12T18:43:56Z","pushed_at":"2016-01-20T13:03:17Z","git_url":"git://github.com/rtomayko/rack-cache.git","ssh_url":"git@github.com:rtomayko/rack-cache.git","clone_url":"https://github.com/rtomayko/rack-cache.git","svn_url":"https://github.com/rtomayko/rack-cache","homepage":"http://rtomayko.github.io/rack-cache/","size":1434,"stargazers_count":626,"watchers_count":626,"language":"Ruby","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":true,"forks_count":101,"mirror_url":null,"open_issues_count":39,"forks":101,"open_issues":39,"watchers":626,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rtomayko/rack-cache/pulls/129"},"html":{"href":"https://github.com/rtomayko/rack-cache/pull/129"},"issue":{"href":"https://api.github.com/repos/rtomayko/rack-cache/issues/129"},"comments":{"href":"https://api.github.com/repos/rtomayko/rack-cache/issues/129/comments"},"review_comments":{"href":"https://api.github.com/repos/rtomayko/rack-cache/pulls/129/comments"},"review_comment":{"href":"https://api.github.com/repos/rtomayko/rack-cache/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rtomayko/rack-cache/pulls/129/commits"},"statuses":{"href":"https://api.github.com/repos/rtomayko/rack-cache/statuses/8ff25d31303a8069ca4b1c30cdc05771f571aad2"}}}}