{"action":"created","comment":{"url":"https://api.github.com/repos/zendframework/zend-cache/pulls/comments/48696550","id":48696550,"diff_hunk":"@@ -0,0 +1,287 @@\n+<?php\n+/**\n+ * Zend Framework (http://framework.zend.com/).\n+ *\n+ * @link      http://github.com/zendframework/zend-cache for the canonical source repository\n+ * @copyright Copyright (c) 2016 Zend Technologies USA Inc. (http://www.zend.com)\n+ * @license   http://framework.zend.com/license/new-bsd New BSD License\n+ */\n+namespace Zend\\Cache\\Psr;\n+\n+use DateTime;\n+use Psr\\Cache\\CacheItemInterface;\n+use Psr\\Cache\\CacheItemPoolInterface;\n+use Zend\\Cache\\Exception;\n+use Zend\\Cache\\Storage\\ClearByNamespaceInterface;\n+use Zend\\Cache\\Storage\\FlushableInterface;\n+use Zend\\Cache\\Storage\\StorageInterface;\n+\n+/**\n+ * PSR-6 cache adapter\n+ *\n+ * @link https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-6-cache.md\n+ * @link https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-6-cache-meta.md\n+ */\n+class CacheItemPoolAdapter implements CacheItemPoolInterface\n+{\n+    /**\n+     * @var StorageInterface\n+     */\n+    private $storage;\n+\n+    /**\n+     * @var CacheItemInterface[]\n+     */\n+    private $deferred = [];\n+\n+    /**\n+     * Constructor.\n+     *\n+     * PSR-6 requires that all implementing libraries support TTL so the given storage adapter must also support static\n+     * TTL or an exception will be raised. Currently the following adapters do *not* support static TTL: Dba,\n+     * Filesystem, Memory, Session and Redis < v2.\n+     *\n+     * @param StorageInterface $storage\n+     *\n+     * @throws CacheException\n+     */\n+    public function __construct(StorageInterface $storage)\n+    {\n+        // all current adapters implement this\n+        if (!$storage instanceof FlushableInterface) {\n+            throw new CacheException(sprintf(\n+                'Storage %s does not implement %s',\n+                get_class($storage),\n+                FlushableInterface::class\n+            ));\n+        }\n+\n+        // we've got to be able to set per-item TTL on write\n+        $capabilities = $storage->getCapabilities();\n+        if (!($capabilities->getStaticTtl() && $capabilities->getMinTtl())) {","path":"src/Psr/CacheItemPoolAdapter.php","position":61,"original_position":61,"commit_id":"879f31f2ee312b5823189948aac0509f6a5e4d61","original_commit_id":"879f31f2ee312b5823189948aac0509f6a5e4d61","user":{"login":"marc-mabe","id":302689,"avatar_url":"https://avatars.githubusercontent.com/u/302689?v=3","gravatar_id":"","url":"https://api.github.com/users/marc-mabe","html_url":"https://github.com/marc-mabe","followers_url":"https://api.github.com/users/marc-mabe/followers","following_url":"https://api.github.com/users/marc-mabe/following{/other_user}","gists_url":"https://api.github.com/users/marc-mabe/gists{/gist_id}","starred_url":"https://api.github.com/users/marc-mabe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marc-mabe/subscriptions","organizations_url":"https://api.github.com/users/marc-mabe/orgs","repos_url":"https://api.github.com/users/marc-mabe/repos","events_url":"https://api.github.com/users/marc-mabe/events{/privacy}","received_events_url":"https://api.github.com/users/marc-mabe/received_events","type":"User","site_admin":false},"body":"I think the check for `&& $capabilities->getMinTtl()` should be removed as this only describes that it's possible to store an item without expiration but not that the adapter doesn't support expiration.","created_at":"2016-01-03T20:11:10Z","updated_at":"2016-01-03T20:11:10Z","html_url":"https://github.com/zendframework/zend-cache/pull/54#discussion_r48696550","pull_request_url":"https://api.github.com/repos/zendframework/zend-cache/pulls/54","_links":{"self":{"href":"https://api.github.com/repos/zendframework/zend-cache/pulls/comments/48696550"},"html":{"href":"https://github.com/zendframework/zend-cache/pull/54#discussion_r48696550"},"pull_request":{"href":"https://api.github.com/repos/zendframework/zend-cache/pulls/54"}}},"pull_request":{"url":"https://api.github.com/repos/zendframework/zend-cache/pulls/54","id":54928401,"html_url":"https://github.com/zendframework/zend-cache/pull/54","diff_url":"https://github.com/zendframework/zend-cache/pull/54.diff","patch_url":"https://github.com/zendframework/zend-cache/pull/54.patch","issue_url":"https://api.github.com/repos/zendframework/zend-cache/issues/54","number":54,"state":"open","locked":false,"title":"Added PSR-6 adapter","user":{"login":"kynx","id":1320145,"avatar_url":"https://avatars.githubusercontent.com/u/1320145?v=3","gravatar_id":"","url":"https://api.github.com/users/kynx","html_url":"https://github.com/kynx","followers_url":"https://api.github.com/users/kynx/followers","following_url":"https://api.github.com/users/kynx/following{/other_user}","gists_url":"https://api.github.com/users/kynx/gists{/gist_id}","starred_url":"https://api.github.com/users/kynx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kynx/subscriptions","organizations_url":"https://api.github.com/users/kynx/orgs","repos_url":"https://api.github.com/users/kynx/repos","events_url":"https://api.github.com/users/kynx/events{/privacy}","received_events_url":"https://api.github.com/users/kynx/received_events","type":"User","site_admin":false},"body":"This PR address #46, adding a [PSR-6](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-6-cache.md) wrapper.\r\n\r\nSome key points:\r\n\r\n* Not all storage adapters are supported, due the PSR-6 requirement that individual cache items must support separate TTLs, set on save. This rules out Dba, Filesystem, Memory, Session and Redis < v2\r\n* PSR-6 [Error Handling](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-6-cache.md#error-handling) requires that most exceptions thrown by the storage adapter be suppressed. I've provided an `ExceptionLogger` so these can be saved to a PSR-3 compatible logger. Some documentation is probably in order!\r\n* There are some useful integration tests at https://github.com/php-cache/integration-tests. I haven't got around to incorporating those yet - only discovered them yesterday.\r\n\r\nHappy New Year!","created_at":"2016-01-03T17:10:28Z","updated_at":"2016-01-03T20:11:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b85d613afbe668a5de8f55259385524c18dc67b3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/zendframework/zend-cache/pulls/54/commits","review_comments_url":"https://api.github.com/repos/zendframework/zend-cache/pulls/54/comments","review_comment_url":"https://api.github.com/repos/zendframework/zend-cache/pulls/comments{/number}","comments_url":"https://api.github.com/repos/zendframework/zend-cache/issues/54/comments","statuses_url":"https://api.github.com/repos/zendframework/zend-cache/statuses/879f31f2ee312b5823189948aac0509f6a5e4d61","head":{"label":"kynx:psr-6","ref":"psr-6","sha":"879f31f2ee312b5823189948aac0509f6a5e4d61","user":{"login":"kynx","id":1320145,"avatar_url":"https://avatars.githubusercontent.com/u/1320145?v=3","gravatar_id":"","url":"https://api.github.com/users/kynx","html_url":"https://github.com/kynx","followers_url":"https://api.github.com/users/kynx/followers","following_url":"https://api.github.com/users/kynx/following{/other_user}","gists_url":"https://api.github.com/users/kynx/gists{/gist_id}","starred_url":"https://api.github.com/users/kynx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kynx/subscriptions","organizations_url":"https://api.github.com/users/kynx/orgs","repos_url":"https://api.github.com/users/kynx/repos","events_url":"https://api.github.com/users/kynx/events{/privacy}","received_events_url":"https://api.github.com/users/kynx/received_events","type":"User","site_admin":false},"repo":{"id":48385602,"name":"zend-cache","full_name":"kynx/zend-cache","owner":{"login":"kynx","id":1320145,"avatar_url":"https://avatars.githubusercontent.com/u/1320145?v=3","gravatar_id":"","url":"https://api.github.com/users/kynx","html_url":"https://github.com/kynx","followers_url":"https://api.github.com/users/kynx/followers","following_url":"https://api.github.com/users/kynx/following{/other_user}","gists_url":"https://api.github.com/users/kynx/gists{/gist_id}","starred_url":"https://api.github.com/users/kynx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kynx/subscriptions","organizations_url":"https://api.github.com/users/kynx/orgs","repos_url":"https://api.github.com/users/kynx/repos","events_url":"https://api.github.com/users/kynx/events{/privacy}","received_events_url":"https://api.github.com/users/kynx/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kynx/zend-cache","description":"","fork":true,"url":"https://api.github.com/repos/kynx/zend-cache","forks_url":"https://api.github.com/repos/kynx/zend-cache/forks","keys_url":"https://api.github.com/repos/kynx/zend-cache/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kynx/zend-cache/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kynx/zend-cache/teams","hooks_url":"https://api.github.com/repos/kynx/zend-cache/hooks","issue_events_url":"https://api.github.com/repos/kynx/zend-cache/issues/events{/number}","events_url":"https://api.github.com/repos/kynx/zend-cache/events","assignees_url":"https://api.github.com/repos/kynx/zend-cache/assignees{/user}","branches_url":"https://api.github.com/repos/kynx/zend-cache/branches{/branch}","tags_url":"https://api.github.com/repos/kynx/zend-cache/tags","blobs_url":"https://api.github.com/repos/kynx/zend-cache/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kynx/zend-cache/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kynx/zend-cache/git/refs{/sha}","trees_url":"https://api.github.com/repos/kynx/zend-cache/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kynx/zend-cache/statuses/{sha}","languages_url":"https://api.github.com/repos/kynx/zend-cache/languages","stargazers_url":"https://api.github.com/repos/kynx/zend-cache/stargazers","contributors_url":"https://api.github.com/repos/kynx/zend-cache/contributors","subscribers_url":"https://api.github.com/repos/kynx/zend-cache/subscribers","subscription_url":"https://api.github.com/repos/kynx/zend-cache/subscription","commits_url":"https://api.github.com/repos/kynx/zend-cache/commits{/sha}","git_commits_url":"https://api.github.com/repos/kynx/zend-cache/git/commits{/sha}","comments_url":"https://api.github.com/repos/kynx/zend-cache/comments{/number}","issue_comment_url":"https://api.github.com/repos/kynx/zend-cache/issues/comments{/number}","contents_url":"https://api.github.com/repos/kynx/zend-cache/contents/{+path}","compare_url":"https://api.github.com/repos/kynx/zend-cache/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kynx/zend-cache/merges","archive_url":"https://api.github.com/repos/kynx/zend-cache/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kynx/zend-cache/downloads","issues_url":"https://api.github.com/repos/kynx/zend-cache/issues{/number}","pulls_url":"https://api.github.com/repos/kynx/zend-cache/pulls{/number}","milestones_url":"https://api.github.com/repos/kynx/zend-cache/milestones{/number}","notifications_url":"https://api.github.com/repos/kynx/zend-cache/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kynx/zend-cache/labels{/name}","releases_url":"https://api.github.com/repos/kynx/zend-cache/releases{/id}","created_at":"2015-12-21T17:42:30Z","updated_at":"2015-12-21T17:42:31Z","pushed_at":"2016-01-03T20:02:20Z","git_url":"git://github.com/kynx/zend-cache.git","ssh_url":"git@github.com:kynx/zend-cache.git","clone_url":"https://github.com/kynx/zend-cache.git","svn_url":"https://github.com/kynx/zend-cache","homepage":null,"size":3579,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"zendframework:develop","ref":"develop","sha":"14b04ebbe1d4494674c08e29ddf037cecff88a85","user":{"login":"zendframework","id":296074,"avatar_url":"https://avatars.githubusercontent.com/u/296074?v=3","gravatar_id":"","url":"https://api.github.com/users/zendframework","html_url":"https://github.com/zendframework","followers_url":"https://api.github.com/users/zendframework/followers","following_url":"https://api.github.com/users/zendframework/following{/other_user}","gists_url":"https://api.github.com/users/zendframework/gists{/gist_id}","starred_url":"https://api.github.com/users/zendframework/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zendframework/subscriptions","organizations_url":"https://api.github.com/users/zendframework/orgs","repos_url":"https://api.github.com/users/zendframework/repos","events_url":"https://api.github.com/users/zendframework/events{/privacy}","received_events_url":"https://api.github.com/users/zendframework/received_events","type":"Organization","site_admin":false},"repo":{"id":35625790,"name":"zend-cache","full_name":"zendframework/zend-cache","owner":{"login":"zendframework","id":296074,"avatar_url":"https://avatars.githubusercontent.com/u/296074?v=3","gravatar_id":"","url":"https://api.github.com/users/zendframework","html_url":"https://github.com/zendframework","followers_url":"https://api.github.com/users/zendframework/followers","following_url":"https://api.github.com/users/zendframework/following{/other_user}","gists_url":"https://api.github.com/users/zendframework/gists{/gist_id}","starred_url":"https://api.github.com/users/zendframework/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zendframework/subscriptions","organizations_url":"https://api.github.com/users/zendframework/orgs","repos_url":"https://api.github.com/users/zendframework/repos","events_url":"https://api.github.com/users/zendframework/events{/privacy}","received_events_url":"https://api.github.com/users/zendframework/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zendframework/zend-cache","description":"","fork":false,"url":"https://api.github.com/repos/zendframework/zend-cache","forks_url":"https://api.github.com/repos/zendframework/zend-cache/forks","keys_url":"https://api.github.com/repos/zendframework/zend-cache/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zendframework/zend-cache/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zendframework/zend-cache/teams","hooks_url":"https://api.github.com/repos/zendframework/zend-cache/hooks","issue_events_url":"https://api.github.com/repos/zendframework/zend-cache/issues/events{/number}","events_url":"https://api.github.com/repos/zendframework/zend-cache/events","assignees_url":"https://api.github.com/repos/zendframework/zend-cache/assignees{/user}","branches_url":"https://api.github.com/repos/zendframework/zend-cache/branches{/branch}","tags_url":"https://api.github.com/repos/zendframework/zend-cache/tags","blobs_url":"https://api.github.com/repos/zendframework/zend-cache/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zendframework/zend-cache/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zendframework/zend-cache/git/refs{/sha}","trees_url":"https://api.github.com/repos/zendframework/zend-cache/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zendframework/zend-cache/statuses/{sha}","languages_url":"https://api.github.com/repos/zendframework/zend-cache/languages","stargazers_url":"https://api.github.com/repos/zendframework/zend-cache/stargazers","contributors_url":"https://api.github.com/repos/zendframework/zend-cache/contributors","subscribers_url":"https://api.github.com/repos/zendframework/zend-cache/subscribers","subscription_url":"https://api.github.com/repos/zendframework/zend-cache/subscription","commits_url":"https://api.github.com/repos/zendframework/zend-cache/commits{/sha}","git_commits_url":"https://api.github.com/repos/zendframework/zend-cache/git/commits{/sha}","comments_url":"https://api.github.com/repos/zendframework/zend-cache/comments{/number}","issue_comment_url":"https://api.github.com/repos/zendframework/zend-cache/issues/comments{/number}","contents_url":"https://api.github.com/repos/zendframework/zend-cache/contents/{+path}","compare_url":"https://api.github.com/repos/zendframework/zend-cache/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zendframework/zend-cache/merges","archive_url":"https://api.github.com/repos/zendframework/zend-cache/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zendframework/zend-cache/downloads","issues_url":"https://api.github.com/repos/zendframework/zend-cache/issues{/number}","pulls_url":"https://api.github.com/repos/zendframework/zend-cache/pulls{/number}","milestones_url":"https://api.github.com/repos/zendframework/zend-cache/milestones{/number}","notifications_url":"https://api.github.com/repos/zendframework/zend-cache/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zendframework/zend-cache/labels{/name}","releases_url":"https://api.github.com/repos/zendframework/zend-cache/releases{/id}","created_at":"2015-05-14T17:33:22Z","updated_at":"2015-12-18T17:11:57Z","pushed_at":"2016-01-03T19:38:00Z","git_url":"git://github.com/zendframework/zend-cache.git","ssh_url":"git@github.com:zendframework/zend-cache.git","clone_url":"https://github.com/zendframework/zend-cache.git","svn_url":"https://github.com/zendframework/zend-cache","homepage":null,"size":3659,"stargazers_count":8,"watchers_count":8,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":17,"mirror_url":null,"open_issues_count":20,"forks":17,"open_issues":20,"watchers":8,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/zendframework/zend-cache/pulls/54"},"html":{"href":"https://github.com/zendframework/zend-cache/pull/54"},"issue":{"href":"https://api.github.com/repos/zendframework/zend-cache/issues/54"},"comments":{"href":"https://api.github.com/repos/zendframework/zend-cache/issues/54/comments"},"review_comments":{"href":"https://api.github.com/repos/zendframework/zend-cache/pulls/54/comments"},"review_comment":{"href":"https://api.github.com/repos/zendframework/zend-cache/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/zendframework/zend-cache/pulls/54/commits"},"statuses":{"href":"https://api.github.com/repos/zendframework/zend-cache/statuses/879f31f2ee312b5823189948aac0509f6a5e4d61"}}}}