GitHub PullRequestReviewCommentEvent at 2014-02-22 16:01:14
Repository: rails
Actor: patricksrobertson
Payload: {"comment":{"url":"https://api.github.com/repos/rails/rails/pulls/comments/9971680","id":9971680,"diff_hunk":"@@ -563,7 +563,7 @@ def find_cached_entry(key, name, options)\n \n         def handle_expired_entry(entry, key, options)\n           if entry && entry.expired?\n-            race_ttl = options[:race_condition_ttl].to_i\n+            race_ttl = options[:race_condition_ttl].try(:to_i)","path":"activesupport/lib/active_support/cache.rb","position":5,"original_position":5,"commit_id":"b640bfe70d281d14763300e7e89a792a4e0cd55c","original_commit_id":"b640bfe70d281d14763300e7e89a792a4e0cd55c","user":{"login":"patricksrobertson","id":115316,"avatar_url":"https://gravatar.com/avatar/718bd208935e684723eba028386f9a92?d=https%3A%2F%2Fidenticons.github.com%2F4a11038add672bf5edd3c9e50057ad9e.png&r=x","gravatar_id":"718bd208935e684723eba028386f9a92","url":"https://api.github.com/users/patricksrobertson","html_url":"https://github.com/patricksrobertson","followers_url":"https://api.github.com/users/patricksrobertson/followers","following_url":"https://api.github.com/users/patricksrobertson/following{/other_user}","gists_url":"https://api.github.com/users/patricksrobertson/gists{/gist_id}","starred_url":"https://api.github.com/users/patricksrobertson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patricksrobertson/subscriptions","organizations_url":"https://api.github.com/users/patricksrobertson/orgs","repos_url":"https://api.github.com/users/patricksrobertson/repos","events_url":"https://api.github.com/users/patricksrobertson/events{/privacy}","received_events_url":"https://api.github.com/users/patricksrobertson/received_events","type":"User","site_admin":false},"body":"consider something like this instead:\r\n```rb\r\ntime_since_expired = Time.now.to_f - entry.expires_at\r\nrace_ttl = options.fetch(:race_condition_ttl, (time_since_expired - 1))\r\nif time_since_expired < race_ttl\r\n#do work\r\n```\r\nThis eliminates the whole nil check premise.","created_at":"2014-02-22T16:01:14Z","updated_at":"2014-02-22T16:01:14Z","html_url":"https://github.com/rails/rails/pull/14157#discussion_r9971680","pull_request_url":"https://api.github.com/repos/rails/rails/pulls/14157","_links":{"self":{"href":"https://api.github.com/repos/rails/rails/pulls/comments/9971680"},"html":{"href":"https://github.com/rails/rails/pull/14157#discussion_r9971680"},"pull_request":{"href":"https://api.github.com/repos/rails/rails/pulls/14157"}}}}