{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/ichnaea/pulls/comments/30126190","id":30126190,"diff_hunk":"@@ -611,16 +614,34 @@ def limit_reached(self):\n             self.redis_client,\n             self.get_ratelimit_key(),\n             maxreq=self.ratelimit,\n-            expire=60,\n+            expire=self.RATE_LIMIT_EXPIRE,\n             fail_on_error=True,\n         )\n \n-    def locate(self, data):\n-        location = self.location_type(query_data=False)\n+    def _get_cache_key(self, cell_data):\n+        return 'fallback_cache_{}'.format(sorted(cell_data.items()))\n \n-        if self.limit_reached():\n-            return location\n+    def _fetch_cached_result(self, data):\n+        all_cell_data = data.get('cell', [])\n \n+        if len(all_cell_data) == 1:\n+            cache_key = self._get_cache_key(all_cell_data[0])\n+            cached_cell = self.redis_client.get(cache_key)\n+            if cached_cell:\n+                return json.loads(cached_cell)","path":"ichnaea/locate/provider.py","position":44,"original_position":44,"commit_id":"7816509e4055bd33b98bc2266df8fcaf595c9aaa","original_commit_id":"7816509e4055bd33b98bc2266df8fcaf595c9aaa","user":{"login":"hannosch","id":483109,"avatar_url":"https://avatars.githubusercontent.com/u/483109?v=3","gravatar_id":"","url":"https://api.github.com/users/hannosch","html_url":"https://github.com/hannosch","followers_url":"https://api.github.com/users/hannosch/followers","following_url":"https://api.github.com/users/hannosch/following{/other_user}","gists_url":"https://api.github.com/users/hannosch/gists{/gist_id}","starred_url":"https://api.github.com/users/hannosch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hannosch/subscriptions","organizations_url":"https://api.github.com/users/hannosch/orgs","repos_url":"https://api.github.com/users/hannosch/repos","events_url":"https://api.github.com/users/hannosch/events{/privacy}","received_events_url":"https://api.github.com/users/hannosch/received_events","type":"User","site_admin":false},"body":"Can you add one more counter to this, something like:\r\n`self.stat_count('fallback.cache.hit')` and `self.stat_count('fallback.cache.miss')`","created_at":"2015-05-12T11:56:43Z","updated_at":"2015-05-12T11:56:43Z","html_url":"https://github.com/mozilla/ichnaea/pull/436#discussion_r30126190","pull_request_url":"https://api.github.com/repos/mozilla/ichnaea/pulls/436","_links":{"self":{"href":"https://api.github.com/repos/mozilla/ichnaea/pulls/comments/30126190"},"html":{"href":"https://github.com/mozilla/ichnaea/pull/436#discussion_r30126190"},"pull_request":{"href":"https://api.github.com/repos/mozilla/ichnaea/pulls/436"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/ichnaea/pulls/436","id":35189691,"html_url":"https://github.com/mozilla/ichnaea/pull/436","diff_url":"https://github.com/mozilla/ichnaea/pull/436.diff","patch_url":"https://github.com/mozilla/ichnaea/pull/436.patch","issue_url":"https://api.github.com/repos/mozilla/ichnaea/issues/436","number":436,"state":"open","locked":false,"title":"Cache single cell results for fallback #421","user":{"login":"jaredkerim","id":119884,"avatar_url":"https://avatars.githubusercontent.com/u/119884?v=3","gravatar_id":"","url":"https://api.github.com/users/jaredkerim","html_url":"https://github.com/jaredkerim","followers_url":"https://api.github.com/users/jaredkerim/followers","following_url":"https://api.github.com/users/jaredkerim/following{/other_user}","gists_url":"https://api.github.com/users/jaredkerim/gists{/gist_id}","starred_url":"https://api.github.com/users/jaredkerim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaredkerim/subscriptions","organizations_url":"https://api.github.com/users/jaredkerim/orgs","repos_url":"https://api.github.com/users/jaredkerim/repos","events_url":"https://api.github.com/users/jaredkerim/events{/privacy}","received_events_url":"https://api.github.com/users/jaredkerim/received_events","type":"User","site_admin":false},"body":"- When we receive only a single cell tower, cache the results\r\n- Add tests\r\n\r\n@hannosch r?","created_at":"2015-05-12T03:07:54Z","updated_at":"2015-05-12T11:56:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"919819cbdcaae1375de16f40136c8dc6a2c41ac7","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/ichnaea/pulls/436/commits","review_comments_url":"https://api.github.com/repos/mozilla/ichnaea/pulls/436/comments","review_comment_url":"https://api.github.com/repos/mozilla/ichnaea/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla/ichnaea/issues/436/comments","statuses_url":"https://api.github.com/repos/mozilla/ichnaea/statuses/7816509e4055bd33b98bc2266df8fcaf595c9aaa","head":{"label":"JaredKerim-Mozilla:421a","ref":"421a","sha":"7816509e4055bd33b98bc2266df8fcaf595c9aaa","user":{"login":"JaredKerim-Mozilla","id":6589361,"avatar_url":"https://avatars.githubusercontent.com/u/6589361?v=3","gravatar_id":"","url":"https://api.github.com/users/JaredKerim-Mozilla","html_url":"https://github.com/JaredKerim-Mozilla","followers_url":"https://api.github.com/users/JaredKerim-Mozilla/followers","following_url":"https://api.github.com/users/JaredKerim-Mozilla/following{/other_user}","gists_url":"https://api.github.com/users/JaredKerim-Mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/JaredKerim-Mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JaredKerim-Mozilla/subscriptions","organizations_url":"https://api.github.com/users/JaredKerim-Mozilla/orgs","repos_url":"https://api.github.com/users/JaredKerim-Mozilla/repos","events_url":"https://api.github.com/users/JaredKerim-Mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/JaredKerim-Mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":24684512,"name":"ichnaea","full_name":"JaredKerim-Mozilla/ichnaea","owner":{"login":"JaredKerim-Mozilla","id":6589361,"avatar_url":"https://avatars.githubusercontent.com/u/6589361?v=3","gravatar_id":"","url":"https://api.github.com/users/JaredKerim-Mozilla","html_url":"https://github.com/JaredKerim-Mozilla","followers_url":"https://api.github.com/users/JaredKerim-Mozilla/followers","following_url":"https://api.github.com/users/JaredKerim-Mozilla/following{/other_user}","gists_url":"https://api.github.com/users/JaredKerim-Mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/JaredKerim-Mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JaredKerim-Mozilla/subscriptions","organizations_url":"https://api.github.com/users/JaredKerim-Mozilla/orgs","repos_url":"https://api.github.com/users/JaredKerim-Mozilla/repos","events_url":"https://api.github.com/users/JaredKerim-Mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/JaredKerim-Mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/JaredKerim-Mozilla/ichnaea","description":"Mozilla Ichnaea","fork":true,"url":"https://api.github.com/repos/JaredKerim-Mozilla/ichnaea","forks_url":"https://api.github.com/repos/JaredKerim-Mozilla/ichnaea/forks","keys_url":"https://api.github.com/repos/JaredKerim-Mozilla/ichnaea/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JaredKerim-Mozilla/ichnaea/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JaredKerim-Mozilla/ichnaea/teams","hooks_url":"https://api.github.com/repos/JaredKerim-Mozilla/ichnaea/hooks","issue_events_url":"https://api.github.com/repos/JaredKerim-Mozilla/ichnaea/issues/events{/number}","events_url":"https://api.github.com/repos/JaredKerim-Mozilla/ichnaea/events","assignees_url":"https://api.github.com/repos/JaredKerim-Mozilla/ichnaea/assignees{/user}","branches_url":"https://api.github.com/repos/JaredKerim-Mozilla/ichnaea/branches{/branch}","tags_url":"https://api.github.com/repos/JaredKerim-Mozilla/ichnaea/tags","blobs_url":"https://api.github.com/repos/JaredKerim-Mozilla/ichnaea/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JaredKerim-Mozilla/ichnaea/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JaredKerim-Mozilla/ichnaea/git/refs{/sha}","trees_url":"https://api.github.com/repos/JaredKerim-Mozilla/ichnaea/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JaredKerim-Mozilla/ichnaea/statuses/{sha}","languages_url":"https://api.github.com/repos/JaredKerim-Mozilla/ichnaea/languages","stargazers_url":"https://api.github.com/repos/JaredKerim-Mozilla/ichnaea/stargazers","contributors_url":"https://api.github.com/repos/JaredKerim-Mozilla/ichnaea/contributors","subscribers_url":"https://api.github.com/repos/JaredKerim-Mozilla/ichnaea/subscribers","subscription_url":"https://api.github.com/repos/JaredKerim-Mozilla/ichnaea/subscription","commits_url":"https://api.github.com/repos/JaredKerim-Mozilla/ichnaea/commits{/sha}","git_commits_url":"https://api.github.com/repos/JaredKerim-Mozilla/ichnaea/git/commits{/sha}","comments_url":"https://api.github.com/repos/JaredKerim-Mozilla/ichnaea/comments{/number}","issue_comment_url":"https://api.github.com/repos/JaredKerim-Mozilla/ichnaea/issues/comments{/number}","contents_url":"https://api.github.com/repos/JaredKerim-Mozilla/ichnaea/contents/{+path}","compare_url":"https://api.github.com/repos/JaredKerim-Mozilla/ichnaea/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JaredKerim-Mozilla/ichnaea/merges","archive_url":"https://api.github.com/repos/JaredKerim-Mozilla/ichnaea/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JaredKerim-Mozilla/ichnaea/downloads","issues_url":"https://api.github.com/repos/JaredKerim-Mozilla/ichnaea/issues{/number}","pulls_url":"https://api.github.com/repos/JaredKerim-Mozilla/ichnaea/pulls{/number}","milestones_url":"https://api.github.com/repos/JaredKerim-Mozilla/ichnaea/milestones{/number}","notifications_url":"https://api.github.com/repos/JaredKerim-Mozilla/ichnaea/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JaredKerim-Mozilla/ichnaea/labels{/name}","releases_url":"https://api.github.com/repos/JaredKerim-Mozilla/ichnaea/releases{/id}","created_at":"2014-10-01T15:51:34Z","updated_at":"2015-05-07T19:44:29Z","pushed_at":"2015-05-12T03:07:32Z","git_url":"git://github.com/JaredKerim-Mozilla/ichnaea.git","ssh_url":"git@github.com:JaredKerim-Mozilla/ichnaea.git","clone_url":"https://github.com/JaredKerim-Mozilla/ichnaea.git","svn_url":"https://github.com/JaredKerim-Mozilla/ichnaea","homepage":"http://location.services.mozilla.com","size":10855,"stargazers_count":0,"watchers_count":0,"language":"Python","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":"mozilla:master","ref":"master","sha":"30e26b9fff35cc51b20f6b267ff54f1ab7192e22","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":9521528,"name":"ichnaea","full_name":"mozilla/ichnaea","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/ichnaea","description":"Mozilla Ichnaea","fork":false,"url":"https://api.github.com/repos/mozilla/ichnaea","forks_url":"https://api.github.com/repos/mozilla/ichnaea/forks","keys_url":"https://api.github.com/repos/mozilla/ichnaea/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/ichnaea/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/ichnaea/teams","hooks_url":"https://api.github.com/repos/mozilla/ichnaea/hooks","issue_events_url":"https://api.github.com/repos/mozilla/ichnaea/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/ichnaea/events","assignees_url":"https://api.github.com/repos/mozilla/ichnaea/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/ichnaea/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/ichnaea/tags","blobs_url":"https://api.github.com/repos/mozilla/ichnaea/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/ichnaea/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/ichnaea/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/ichnaea/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/ichnaea/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/ichnaea/languages","stargazers_url":"https://api.github.com/repos/mozilla/ichnaea/stargazers","contributors_url":"https://api.github.com/repos/mozilla/ichnaea/contributors","subscribers_url":"https://api.github.com/repos/mozilla/ichnaea/subscribers","subscription_url":"https://api.github.com/repos/mozilla/ichnaea/subscription","commits_url":"https://api.github.com/repos/mozilla/ichnaea/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/ichnaea/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/ichnaea/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/ichnaea/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/ichnaea/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/ichnaea/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/ichnaea/merges","archive_url":"https://api.github.com/repos/mozilla/ichnaea/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/ichnaea/downloads","issues_url":"https://api.github.com/repos/mozilla/ichnaea/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/ichnaea/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/ichnaea/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/ichnaea/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/ichnaea/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/ichnaea/releases{/id}","created_at":"2013-04-18T12:51:09Z","updated_at":"2015-05-08T11:28:33Z","pushed_at":"2015-05-12T03:07:54Z","git_url":"git://github.com/mozilla/ichnaea.git","ssh_url":"git@github.com:mozilla/ichnaea.git","clone_url":"https://github.com/mozilla/ichnaea.git","svn_url":"https://github.com/mozilla/ichnaea","homepage":"http://location.services.mozilla.com","size":14551,"stargazers_count":224,"watchers_count":224,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":40,"mirror_url":null,"open_issues_count":75,"forks":40,"open_issues":75,"watchers":224,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/ichnaea/pulls/436"},"html":{"href":"https://github.com/mozilla/ichnaea/pull/436"},"issue":{"href":"https://api.github.com/repos/mozilla/ichnaea/issues/436"},"comments":{"href":"https://api.github.com/repos/mozilla/ichnaea/issues/436/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/ichnaea/pulls/436/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/ichnaea/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla/ichnaea/pulls/436/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/ichnaea/statuses/7816509e4055bd33b98bc2266df8fcaf595c9aaa"}}}}