{"action":"created","comment":{"url":"https://api.github.com/repos/doctrine/cache/pulls/comments/48426742","id":48426742,"diff_hunk":"@@ -59,8 +92,8 @@ protected function doContains($id)\n      */\n     protected function doSave($id, $data, $lifeTime = 0)\n     {\n-        $this->data[$id] = $data;\n-\n+        $ttl = $lifeTime > 0 ? time()+$lifeTime : false;\n+        $this->data[$id] = array('content'=>$data, 'ttl'=>$ttl);","path":"lib/Doctrine/Common/Cache/ArrayCache.php","position":62,"original_position":62,"commit_id":"1c08c449d2e9e12350d30ab73790500f6766f1e4","original_commit_id":"1c08c449d2e9e12350d30ab73790500f6766f1e4","user":{"login":"Tobion","id":610090,"avatar_url":"https://avatars.githubusercontent.com/u/610090?v=3","gravatar_id":"","url":"https://api.github.com/users/Tobion","html_url":"https://github.com/Tobion","followers_url":"https://api.github.com/users/Tobion/followers","following_url":"https://api.github.com/users/Tobion/following{/other_user}","gists_url":"https://api.github.com/users/Tobion/gists{/gist_id}","starred_url":"https://api.github.com/users/Tobion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tobion/subscriptions","organizations_url":"https://api.github.com/users/Tobion/orgs","repos_url":"https://api.github.com/users/Tobion/repos","events_url":"https://api.github.com/users/Tobion/events{/privacy}","received_events_url":"https://api.github.com/users/Tobion/received_events","type":"User","site_admin":false},"body":"this should use numeric indexes instead of `content` and `ttl` to save memory. or use different arrays for data and ttl.","created_at":"2015-12-24T21:56:47Z","updated_at":"2015-12-24T21:56:47Z","html_url":"https://github.com/doctrine/cache/pull/130#discussion_r48426742","pull_request_url":"https://api.github.com/repos/doctrine/cache/pulls/130","_links":{"self":{"href":"https://api.github.com/repos/doctrine/cache/pulls/comments/48426742"},"html":{"href":"https://github.com/doctrine/cache/pull/130#discussion_r48426742"},"pull_request":{"href":"https://api.github.com/repos/doctrine/cache/pulls/130"}}},"pull_request":{"url":"https://api.github.com/repos/doctrine/cache/pulls/130","id":54230338,"html_url":"https://github.com/doctrine/cache/pull/130","diff_url":"https://github.com/doctrine/cache/pull/130.diff","patch_url":"https://github.com/doctrine/cache/pull/130.patch","issue_url":"https://api.github.com/repos/doctrine/cache/issues/130","number":130,"state":"open","locked":false,"title":"Added support for stats and ttl on ArrayCache","user":{"login":"victorjonsson","id":429182,"avatar_url":"https://avatars.githubusercontent.com/u/429182?v=3","gravatar_id":"","url":"https://api.github.com/users/victorjonsson","html_url":"https://github.com/victorjonsson","followers_url":"https://api.github.com/users/victorjonsson/followers","following_url":"https://api.github.com/users/victorjonsson/following{/other_user}","gists_url":"https://api.github.com/users/victorjonsson/gists{/gist_id}","starred_url":"https://api.github.com/users/victorjonsson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/victorjonsson/subscriptions","organizations_url":"https://api.github.com/users/victorjonsson/orgs","repos_url":"https://api.github.com/users/victorjonsson/repos","events_url":"https://api.github.com/users/victorjonsson/events{/privacy}","received_events_url":"https://api.github.com/users/victorjonsson/received_events","type":"User","site_admin":false},"body":"I had some long-time running scripts that was heavily using the ArrayCache. After a while I got some unexpected behaviour, and at first I couldn't figure out why. Imagine my surprise when I discovered that the ttl-feature was missing, it explained a lot.\r\n\r\nSo here you have my take on how it could be implemented. I also added support for hit ratio. Let me know what you think!","created_at":"2015-12-21T08:14:41Z","updated_at":"2015-12-24T21:56:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"83e62563b11f71dd3462287f25ccff049d32a5fd","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/doctrine/cache/pulls/130/commits","review_comments_url":"https://api.github.com/repos/doctrine/cache/pulls/130/comments","review_comment_url":"https://api.github.com/repos/doctrine/cache/pulls/comments{/number}","comments_url":"https://api.github.com/repos/doctrine/cache/issues/130/comments","statuses_url":"https://api.github.com/repos/doctrine/cache/statuses/1c08c449d2e9e12350d30ab73790500f6766f1e4","head":{"label":"victorjonsson:master","ref":"master","sha":"1c08c449d2e9e12350d30ab73790500f6766f1e4","user":{"login":"victorjonsson","id":429182,"avatar_url":"https://avatars.githubusercontent.com/u/429182?v=3","gravatar_id":"","url":"https://api.github.com/users/victorjonsson","html_url":"https://github.com/victorjonsson","followers_url":"https://api.github.com/users/victorjonsson/followers","following_url":"https://api.github.com/users/victorjonsson/following{/other_user}","gists_url":"https://api.github.com/users/victorjonsson/gists{/gist_id}","starred_url":"https://api.github.com/users/victorjonsson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/victorjonsson/subscriptions","organizations_url":"https://api.github.com/users/victorjonsson/orgs","repos_url":"https://api.github.com/users/victorjonsson/repos","events_url":"https://api.github.com/users/victorjonsson/events{/privacy}","received_events_url":"https://api.github.com/users/victorjonsson/received_events","type":"User","site_admin":false},"repo":{"id":48357523,"name":"cache","full_name":"victorjonsson/cache","owner":{"login":"victorjonsson","id":429182,"avatar_url":"https://avatars.githubusercontent.com/u/429182?v=3","gravatar_id":"","url":"https://api.github.com/users/victorjonsson","html_url":"https://github.com/victorjonsson","followers_url":"https://api.github.com/users/victorjonsson/followers","following_url":"https://api.github.com/users/victorjonsson/following{/other_user}","gists_url":"https://api.github.com/users/victorjonsson/gists{/gist_id}","starred_url":"https://api.github.com/users/victorjonsson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/victorjonsson/subscriptions","organizations_url":"https://api.github.com/users/victorjonsson/orgs","repos_url":"https://api.github.com/users/victorjonsson/repos","events_url":"https://api.github.com/users/victorjonsson/events{/privacy}","received_events_url":"https://api.github.com/users/victorjonsson/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/victorjonsson/cache","description":"Doctrine Cache component","fork":true,"url":"https://api.github.com/repos/victorjonsson/cache","forks_url":"https://api.github.com/repos/victorjonsson/cache/forks","keys_url":"https://api.github.com/repos/victorjonsson/cache/keys{/key_id}","collaborators_url":"https://api.github.com/repos/victorjonsson/cache/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/victorjonsson/cache/teams","hooks_url":"https://api.github.com/repos/victorjonsson/cache/hooks","issue_events_url":"https://api.github.com/repos/victorjonsson/cache/issues/events{/number}","events_url":"https://api.github.com/repos/victorjonsson/cache/events","assignees_url":"https://api.github.com/repos/victorjonsson/cache/assignees{/user}","branches_url":"https://api.github.com/repos/victorjonsson/cache/branches{/branch}","tags_url":"https://api.github.com/repos/victorjonsson/cache/tags","blobs_url":"https://api.github.com/repos/victorjonsson/cache/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/victorjonsson/cache/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/victorjonsson/cache/git/refs{/sha}","trees_url":"https://api.github.com/repos/victorjonsson/cache/git/trees{/sha}","statuses_url":"https://api.github.com/repos/victorjonsson/cache/statuses/{sha}","languages_url":"https://api.github.com/repos/victorjonsson/cache/languages","stargazers_url":"https://api.github.com/repos/victorjonsson/cache/stargazers","contributors_url":"https://api.github.com/repos/victorjonsson/cache/contributors","subscribers_url":"https://api.github.com/repos/victorjonsson/cache/subscribers","subscription_url":"https://api.github.com/repos/victorjonsson/cache/subscription","commits_url":"https://api.github.com/repos/victorjonsson/cache/commits{/sha}","git_commits_url":"https://api.github.com/repos/victorjonsson/cache/git/commits{/sha}","comments_url":"https://api.github.com/repos/victorjonsson/cache/comments{/number}","issue_comment_url":"https://api.github.com/repos/victorjonsson/cache/issues/comments{/number}","contents_url":"https://api.github.com/repos/victorjonsson/cache/contents/{+path}","compare_url":"https://api.github.com/repos/victorjonsson/cache/compare/{base}...{head}","merges_url":"https://api.github.com/repos/victorjonsson/cache/merges","archive_url":"https://api.github.com/repos/victorjonsson/cache/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/victorjonsson/cache/downloads","issues_url":"https://api.github.com/repos/victorjonsson/cache/issues{/number}","pulls_url":"https://api.github.com/repos/victorjonsson/cache/pulls{/number}","milestones_url":"https://api.github.com/repos/victorjonsson/cache/milestones{/number}","notifications_url":"https://api.github.com/repos/victorjonsson/cache/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/victorjonsson/cache/labels{/name}","releases_url":"https://api.github.com/repos/victorjonsson/cache/releases{/id}","created_at":"2015-12-21T07:31:21Z","updated_at":"2015-12-21T07:31:22Z","pushed_at":"2015-12-21T08:04:12Z","git_url":"git://github.com/victorjonsson/cache.git","ssh_url":"git@github.com:victorjonsson/cache.git","clone_url":"https://github.com/victorjonsson/cache.git","svn_url":"https://github.com/victorjonsson/cache","homepage":null,"size":408,"stargazers_count":0,"watchers_count":0,"language":"PHP","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":"doctrine:master","ref":"master","sha":"bc23e0f46da064cbc53c1b1243472477487ef754","user":{"login":"doctrine","id":209254,"avatar_url":"https://avatars.githubusercontent.com/u/209254?v=3","gravatar_id":"","url":"https://api.github.com/users/doctrine","html_url":"https://github.com/doctrine","followers_url":"https://api.github.com/users/doctrine/followers","following_url":"https://api.github.com/users/doctrine/following{/other_user}","gists_url":"https://api.github.com/users/doctrine/gists{/gist_id}","starred_url":"https://api.github.com/users/doctrine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/doctrine/subscriptions","organizations_url":"https://api.github.com/users/doctrine/orgs","repos_url":"https://api.github.com/users/doctrine/repos","events_url":"https://api.github.com/users/doctrine/events{/privacy}","received_events_url":"https://api.github.com/users/doctrine/received_events","type":"Organization","site_admin":false},"repo":{"id":7550057,"name":"cache","full_name":"doctrine/cache","owner":{"login":"doctrine","id":209254,"avatar_url":"https://avatars.githubusercontent.com/u/209254?v=3","gravatar_id":"","url":"https://api.github.com/users/doctrine","html_url":"https://github.com/doctrine","followers_url":"https://api.github.com/users/doctrine/followers","following_url":"https://api.github.com/users/doctrine/following{/other_user}","gists_url":"https://api.github.com/users/doctrine/gists{/gist_id}","starred_url":"https://api.github.com/users/doctrine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/doctrine/subscriptions","organizations_url":"https://api.github.com/users/doctrine/orgs","repos_url":"https://api.github.com/users/doctrine/repos","events_url":"https://api.github.com/users/doctrine/events{/privacy}","received_events_url":"https://api.github.com/users/doctrine/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/doctrine/cache","description":"Doctrine Cache component","fork":false,"url":"https://api.github.com/repos/doctrine/cache","forks_url":"https://api.github.com/repos/doctrine/cache/forks","keys_url":"https://api.github.com/repos/doctrine/cache/keys{/key_id}","collaborators_url":"https://api.github.com/repos/doctrine/cache/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/doctrine/cache/teams","hooks_url":"https://api.github.com/repos/doctrine/cache/hooks","issue_events_url":"https://api.github.com/repos/doctrine/cache/issues/events{/number}","events_url":"https://api.github.com/repos/doctrine/cache/events","assignees_url":"https://api.github.com/repos/doctrine/cache/assignees{/user}","branches_url":"https://api.github.com/repos/doctrine/cache/branches{/branch}","tags_url":"https://api.github.com/repos/doctrine/cache/tags","blobs_url":"https://api.github.com/repos/doctrine/cache/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/doctrine/cache/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/doctrine/cache/git/refs{/sha}","trees_url":"https://api.github.com/repos/doctrine/cache/git/trees{/sha}","statuses_url":"https://api.github.com/repos/doctrine/cache/statuses/{sha}","languages_url":"https://api.github.com/repos/doctrine/cache/languages","stargazers_url":"https://api.github.com/repos/doctrine/cache/stargazers","contributors_url":"https://api.github.com/repos/doctrine/cache/contributors","subscribers_url":"https://api.github.com/repos/doctrine/cache/subscribers","subscription_url":"https://api.github.com/repos/doctrine/cache/subscription","commits_url":"https://api.github.com/repos/doctrine/cache/commits{/sha}","git_commits_url":"https://api.github.com/repos/doctrine/cache/git/commits{/sha}","comments_url":"https://api.github.com/repos/doctrine/cache/comments{/number}","issue_comment_url":"https://api.github.com/repos/doctrine/cache/issues/comments{/number}","contents_url":"https://api.github.com/repos/doctrine/cache/contents/{+path}","compare_url":"https://api.github.com/repos/doctrine/cache/compare/{base}...{head}","merges_url":"https://api.github.com/repos/doctrine/cache/merges","archive_url":"https://api.github.com/repos/doctrine/cache/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/doctrine/cache/downloads","issues_url":"https://api.github.com/repos/doctrine/cache/issues{/number}","pulls_url":"https://api.github.com/repos/doctrine/cache/pulls{/number}","milestones_url":"https://api.github.com/repos/doctrine/cache/milestones{/number}","notifications_url":"https://api.github.com/repos/doctrine/cache/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/doctrine/cache/labels{/name}","releases_url":"https://api.github.com/repos/doctrine/cache/releases{/id}","created_at":"2013-01-10T22:37:43Z","updated_at":"2015-12-16T11:11:50Z","pushed_at":"2015-12-21T08:14:41Z","git_url":"git://github.com/doctrine/cache.git","ssh_url":"git@github.com:doctrine/cache.git","clone_url":"https://github.com/doctrine/cache.git","svn_url":"https://github.com/doctrine/cache","homepage":null,"size":720,"stargazers_count":191,"watchers_count":191,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":107,"mirror_url":null,"open_issues_count":7,"forks":107,"open_issues":7,"watchers":191,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/doctrine/cache/pulls/130"},"html":{"href":"https://github.com/doctrine/cache/pull/130"},"issue":{"href":"https://api.github.com/repos/doctrine/cache/issues/130"},"comments":{"href":"https://api.github.com/repos/doctrine/cache/issues/130/comments"},"review_comments":{"href":"https://api.github.com/repos/doctrine/cache/pulls/130/comments"},"review_comment":{"href":"https://api.github.com/repos/doctrine/cache/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/doctrine/cache/pulls/130/commits"},"statuses":{"href":"https://api.github.com/repos/doctrine/cache/statuses/1c08c449d2e9e12350d30ab73790500f6766f1e4"}}}}