{"action":"created","comment":{"url":"https://api.github.com/repos/symfony/symfony/pulls/comments/51714450","id":51714450,"diff_hunk":"@@ -0,0 +1,107 @@\n+<?php\n+\n+/*\n+ * This file is part of the Symfony package.\n+ *\n+ * (c) Fabien Potencier <fabien@symfony.com>\n+ *\n+ * For the full copyright and license information, please view the LICENSE\n+ * file that was distributed with this source code.\n+ */\n+\n+namespace Symfony\\Component\\Cache\\Adapter;\n+\n+/**\n+ * @author Aurimas Niekis <aurimas@niekis.lt>\n+ */\n+class RedisAdapter extends AbstractAdapter\n+{\n+    /**\n+     * @var \\Redis\n+     */\n+    private $redis;\n+\n+    /**\n+     * @param \\Redis $redisConnection\n+     * @param string $namespace\n+     * @param int    $defaultLifetime\n+     */\n+    public function __construct($redisConnection, $namespace = '', $defaultLifetime = 0)\n+    {\n+        $this->redis = $redisConnection;\n+\n+        parent::__construct($namespace, $defaultLifetime);\n+    }\n+\n+    /**\n+     * {@inheritdoc}\n+     */\n+    protected function doFetch(array $ids)\n+    {\n+        $values = $this->redis->getMultiple($ids);\n+\n+        $index = 0;\n+        $result = [];\n+\n+        foreach ($ids as $id) {\n+            $value = $values[$index++];\n+\n+            if (false === $value) {\n+                continue;\n+            }\n+\n+            $result[$id] = unserialize($value);\n+        }\n+\n+        return $result;\n+    }\n+\n+    /**\n+     * {@inheritdoc}\n+     */\n+    protected function doHave($id)\n+    {\n+        return $this->redis->exists($id);\n+    }\n+\n+    /**\n+     * {@inheritdoc}\n+     */\n+    protected function doClear()\n+    {\n+        return $this->redis->flushDB();\n+    }\n+\n+    /**\n+     * {@inheritdoc}\n+     */\n+    protected function doDelete(array $ids)\n+    {\n+        call_user_func_array([$this->redis, 'delete'], $ids);\n+\n+        return true;\n+    }\n+\n+    /**\n+     * {@inheritdoc}\n+     */\n+    protected function doSave(array $values, $lifetime)\n+    {\n+        $failed = [];\n+        foreach ($values as $key => $value) {\n+            $value = serialize($value);\n+\n+            if ($lifetime < 1) {\n+                $response = $this->redis->set($key, $value);\n+            } else {\n+                $response = $this->redis->setex($key, $lifetime, $value);","path":"src/Symfony/Component/Cache/Adapter/RedisAdapter.php","position":97,"original_position":97,"commit_id":"610932441131d505819739542367a668651053bc","original_commit_id":"f8358291cc7de34de9a02566407ba398ba8ce497","user":{"login":"nicolas-grekas","id":243674,"avatar_url":"https://avatars.githubusercontent.com/u/243674?v=3","gravatar_id":"","url":"https://api.github.com/users/nicolas-grekas","html_url":"https://github.com/nicolas-grekas","followers_url":"https://api.github.com/users/nicolas-grekas/followers","following_url":"https://api.github.com/users/nicolas-grekas/following{/other_user}","gists_url":"https://api.github.com/users/nicolas-grekas/gists{/gist_id}","starred_url":"https://api.github.com/users/nicolas-grekas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicolas-grekas/subscriptions","organizations_url":"https://api.github.com/users/nicolas-grekas/orgs","repos_url":"https://api.github.com/users/nicolas-grekas/repos","events_url":"https://api.github.com/users/nicolas-grekas/events{/privacy}","received_events_url":"https://api.github.com/users/nicolas-grekas/received_events","type":"User","site_admin":false},"body":"lifetime is in second but redis expects millisecond, isn't it?","created_at":"2016-02-03T12:31:27Z","updated_at":"2016-02-03T12:31:27Z","html_url":"https://github.com/symfony/symfony/pull/17441#discussion_r51714450","pull_request_url":"https://api.github.com/repos/symfony/symfony/pulls/17441","_links":{"self":{"href":"https://api.github.com/repos/symfony/symfony/pulls/comments/51714450"},"html":{"href":"https://github.com/symfony/symfony/pull/17441#discussion_r51714450"},"pull_request":{"href":"https://api.github.com/repos/symfony/symfony/pulls/17441"}}},"pull_request":{"url":"https://api.github.com/repos/symfony/symfony/pulls/17441","id":56467803,"html_url":"https://github.com/symfony/symfony/pull/17441","diff_url":"https://github.com/symfony/symfony/pull/17441.diff","patch_url":"https://github.com/symfony/symfony/pull/17441.patch","issue_url":"https://api.github.com/repos/symfony/symfony/issues/17441","number":17441,"state":"open","locked":false,"title":"[Cache] Added RedisAdapter","user":{"login":"gcds","id":15481,"avatar_url":"https://avatars.githubusercontent.com/u/15481?v=3","gravatar_id":"","url":"https://api.github.com/users/gcds","html_url":"https://github.com/gcds","followers_url":"https://api.github.com/users/gcds/followers","following_url":"https://api.github.com/users/gcds/following{/other_user}","gists_url":"https://api.github.com/users/gcds/gists{/gist_id}","starred_url":"https://api.github.com/users/gcds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gcds/subscriptions","organizations_url":"https://api.github.com/users/gcds/orgs","repos_url":"https://api.github.com/users/gcds/repos","events_url":"https://api.github.com/users/gcds/events{/privacy}","received_events_url":"https://api.github.com/users/gcds/received_events","type":"User","site_admin":false},"body":"| Q             | A\r\n| ------------- | ---\r\n| Bug fix?      | no\r\n| New feature?  | yes\r\n| BC breaks?    | no\r\n| Deprecations? | no\r\n| Tests pass?   | yes\r\n| License       | MIT\r\n\r\nI have added RedisAdapter. I haven't hardcoded that it would use *phpredis* extension version client because there is many other clients which provide same API so to support them I left open. For test purpose I wrote a *FakeRedis* client implementation which acts like real just stores everything in array.\r\n\r\nIf we choose to use extension version I will remove FakeRedis and add variable requirement for `\\Redis` type. But we will need redis instance on tests... Or somehow find way to mock it (We will need extend all cache/integration-test tests because of mocking)","created_at":"2016-01-19T13:48:48Z","updated_at":"2016-02-03T12:31:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"23951e3cbd7d864dff5209388bc6ffabe2101d7d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/symfony/symfony/pulls/17441/commits","review_comments_url":"https://api.github.com/repos/symfony/symfony/pulls/17441/comments","review_comment_url":"https://api.github.com/repos/symfony/symfony/pulls/comments{/number}","comments_url":"https://api.github.com/repos/symfony/symfony/issues/17441/comments","statuses_url":"https://api.github.com/repos/symfony/symfony/statuses/610932441131d505819739542367a668651053bc","head":{"label":"gcds:redis_adapter","ref":"redis_adapter","sha":"610932441131d505819739542367a668651053bc","user":{"login":"gcds","id":15481,"avatar_url":"https://avatars.githubusercontent.com/u/15481?v=3","gravatar_id":"","url":"https://api.github.com/users/gcds","html_url":"https://github.com/gcds","followers_url":"https://api.github.com/users/gcds/followers","following_url":"https://api.github.com/users/gcds/following{/other_user}","gists_url":"https://api.github.com/users/gcds/gists{/gist_id}","starred_url":"https://api.github.com/users/gcds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gcds/subscriptions","organizations_url":"https://api.github.com/users/gcds/orgs","repos_url":"https://api.github.com/users/gcds/repos","events_url":"https://api.github.com/users/gcds/events{/privacy}","received_events_url":"https://api.github.com/users/gcds/received_events","type":"User","site_admin":false},"repo":{"id":39765999,"name":"symfony","full_name":"gcds/symfony","owner":{"login":"gcds","id":15481,"avatar_url":"https://avatars.githubusercontent.com/u/15481?v=3","gravatar_id":"","url":"https://api.github.com/users/gcds","html_url":"https://github.com/gcds","followers_url":"https://api.github.com/users/gcds/followers","following_url":"https://api.github.com/users/gcds/following{/other_user}","gists_url":"https://api.github.com/users/gcds/gists{/gist_id}","starred_url":"https://api.github.com/users/gcds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gcds/subscriptions","organizations_url":"https://api.github.com/users/gcds/orgs","repos_url":"https://api.github.com/users/gcds/repos","events_url":"https://api.github.com/users/gcds/events{/privacy}","received_events_url":"https://api.github.com/users/gcds/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gcds/symfony","description":"The Symfony PHP framework","fork":true,"url":"https://api.github.com/repos/gcds/symfony","forks_url":"https://api.github.com/repos/gcds/symfony/forks","keys_url":"https://api.github.com/repos/gcds/symfony/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gcds/symfony/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gcds/symfony/teams","hooks_url":"https://api.github.com/repos/gcds/symfony/hooks","issue_events_url":"https://api.github.com/repos/gcds/symfony/issues/events{/number}","events_url":"https://api.github.com/repos/gcds/symfony/events","assignees_url":"https://api.github.com/repos/gcds/symfony/assignees{/user}","branches_url":"https://api.github.com/repos/gcds/symfony/branches{/branch}","tags_url":"https://api.github.com/repos/gcds/symfony/tags","blobs_url":"https://api.github.com/repos/gcds/symfony/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gcds/symfony/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gcds/symfony/git/refs{/sha}","trees_url":"https://api.github.com/repos/gcds/symfony/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gcds/symfony/statuses/{sha}","languages_url":"https://api.github.com/repos/gcds/symfony/languages","stargazers_url":"https://api.github.com/repos/gcds/symfony/stargazers","contributors_url":"https://api.github.com/repos/gcds/symfony/contributors","subscribers_url":"https://api.github.com/repos/gcds/symfony/subscribers","subscription_url":"https://api.github.com/repos/gcds/symfony/subscription","commits_url":"https://api.github.com/repos/gcds/symfony/commits{/sha}","git_commits_url":"https://api.github.com/repos/gcds/symfony/git/commits{/sha}","comments_url":"https://api.github.com/repos/gcds/symfony/comments{/number}","issue_comment_url":"https://api.github.com/repos/gcds/symfony/issues/comments{/number}","contents_url":"https://api.github.com/repos/gcds/symfony/contents/{+path}","compare_url":"https://api.github.com/repos/gcds/symfony/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gcds/symfony/merges","archive_url":"https://api.github.com/repos/gcds/symfony/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gcds/symfony/downloads","issues_url":"https://api.github.com/repos/gcds/symfony/issues{/number}","pulls_url":"https://api.github.com/repos/gcds/symfony/pulls{/number}","milestones_url":"https://api.github.com/repos/gcds/symfony/milestones{/number}","notifications_url":"https://api.github.com/repos/gcds/symfony/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gcds/symfony/labels{/name}","releases_url":"https://api.github.com/repos/gcds/symfony/releases{/id}","deployments_url":"https://api.github.com/repos/gcds/symfony/deployments","created_at":"2015-07-27T09:26:01Z","updated_at":"2015-07-27T09:26:18Z","pushed_at":"2016-02-03T12:30:20Z","git_url":"git://github.com/gcds/symfony.git","ssh_url":"git@github.com:gcds/symfony.git","clone_url":"https://github.com/gcds/symfony.git","svn_url":"https://github.com/gcds/symfony","homepage":"symfony.com","size":65728,"stargazers_count":0,"watchers_count":0,"language":"PHP","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":"2.8"}},"base":{"label":"symfony:master","ref":"master","sha":"cc84be9d53aefcd4a9a68ff9363a192453b979f8","user":{"login":"symfony","id":143937,"avatar_url":"https://avatars.githubusercontent.com/u/143937?v=3","gravatar_id":"","url":"https://api.github.com/users/symfony","html_url":"https://github.com/symfony","followers_url":"https://api.github.com/users/symfony/followers","following_url":"https://api.github.com/users/symfony/following{/other_user}","gists_url":"https://api.github.com/users/symfony/gists{/gist_id}","starred_url":"https://api.github.com/users/symfony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/symfony/subscriptions","organizations_url":"https://api.github.com/users/symfony/orgs","repos_url":"https://api.github.com/users/symfony/repos","events_url":"https://api.github.com/users/symfony/events{/privacy}","received_events_url":"https://api.github.com/users/symfony/received_events","type":"Organization","site_admin":false},"repo":{"id":458058,"name":"symfony","full_name":"symfony/symfony","owner":{"login":"symfony","id":143937,"avatar_url":"https://avatars.githubusercontent.com/u/143937?v=3","gravatar_id":"","url":"https://api.github.com/users/symfony","html_url":"https://github.com/symfony","followers_url":"https://api.github.com/users/symfony/followers","following_url":"https://api.github.com/users/symfony/following{/other_user}","gists_url":"https://api.github.com/users/symfony/gists{/gist_id}","starred_url":"https://api.github.com/users/symfony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/symfony/subscriptions","organizations_url":"https://api.github.com/users/symfony/orgs","repos_url":"https://api.github.com/users/symfony/repos","events_url":"https://api.github.com/users/symfony/events{/privacy}","received_events_url":"https://api.github.com/users/symfony/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/symfony/symfony","description":"The Symfony PHP framework","fork":false,"url":"https://api.github.com/repos/symfony/symfony","forks_url":"https://api.github.com/repos/symfony/symfony/forks","keys_url":"https://api.github.com/repos/symfony/symfony/keys{/key_id}","collaborators_url":"https://api.github.com/repos/symfony/symfony/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/symfony/symfony/teams","hooks_url":"https://api.github.com/repos/symfony/symfony/hooks","issue_events_url":"https://api.github.com/repos/symfony/symfony/issues/events{/number}","events_url":"https://api.github.com/repos/symfony/symfony/events","assignees_url":"https://api.github.com/repos/symfony/symfony/assignees{/user}","branches_url":"https://api.github.com/repos/symfony/symfony/branches{/branch}","tags_url":"https://api.github.com/repos/symfony/symfony/tags","blobs_url":"https://api.github.com/repos/symfony/symfony/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/symfony/symfony/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/symfony/symfony/git/refs{/sha}","trees_url":"https://api.github.com/repos/symfony/symfony/git/trees{/sha}","statuses_url":"https://api.github.com/repos/symfony/symfony/statuses/{sha}","languages_url":"https://api.github.com/repos/symfony/symfony/languages","stargazers_url":"https://api.github.com/repos/symfony/symfony/stargazers","contributors_url":"https://api.github.com/repos/symfony/symfony/contributors","subscribers_url":"https://api.github.com/repos/symfony/symfony/subscribers","subscription_url":"https://api.github.com/repos/symfony/symfony/subscription","commits_url":"https://api.github.com/repos/symfony/symfony/commits{/sha}","git_commits_url":"https://api.github.com/repos/symfony/symfony/git/commits{/sha}","comments_url":"https://api.github.com/repos/symfony/symfony/comments{/number}","issue_comment_url":"https://api.github.com/repos/symfony/symfony/issues/comments{/number}","contents_url":"https://api.github.com/repos/symfony/symfony/contents/{+path}","compare_url":"https://api.github.com/repos/symfony/symfony/compare/{base}...{head}","merges_url":"https://api.github.com/repos/symfony/symfony/merges","archive_url":"https://api.github.com/repos/symfony/symfony/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/symfony/symfony/downloads","issues_url":"https://api.github.com/repos/symfony/symfony/issues{/number}","pulls_url":"https://api.github.com/repos/symfony/symfony/pulls{/number}","milestones_url":"https://api.github.com/repos/symfony/symfony/milestones{/number}","notifications_url":"https://api.github.com/repos/symfony/symfony/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/symfony/symfony/labels{/name}","releases_url":"https://api.github.com/repos/symfony/symfony/releases{/id}","deployments_url":"https://api.github.com/repos/symfony/symfony/deployments","created_at":"2010-01-04T14:21:21Z","updated_at":"2016-02-03T12:05:25Z","pushed_at":"2016-02-03T12:30:21Z","git_url":"git://github.com/symfony/symfony.git","ssh_url":"git@github.com:symfony/symfony.git","clone_url":"https://github.com/symfony/symfony.git","svn_url":"https://github.com/symfony/symfony","homepage":"symfony.com","size":100735,"stargazers_count":11667,"watchers_count":11667,"language":"PHP","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":4586,"mirror_url":null,"open_issues_count":782,"forks":4586,"open_issues":782,"watchers":11667,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/symfony/symfony/pulls/17441"},"html":{"href":"https://github.com/symfony/symfony/pull/17441"},"issue":{"href":"https://api.github.com/repos/symfony/symfony/issues/17441"},"comments":{"href":"https://api.github.com/repos/symfony/symfony/issues/17441/comments"},"review_comments":{"href":"https://api.github.com/repos/symfony/symfony/pulls/17441/comments"},"review_comment":{"href":"https://api.github.com/repos/symfony/symfony/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/symfony/symfony/pulls/17441/commits"},"statuses":{"href":"https://api.github.com/repos/symfony/symfony/statuses/610932441131d505819739542367a668651053bc"}}}}