From f70eca0208e25de09bc5177c099ee42669415312 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Mon, 18 Jan 2016 20:32:28 +0100 Subject: [PATCH 1/3] Using callable --- src/RedisCachePool.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/RedisCachePool.php b/src/RedisCachePool.php index b97fb73..55fe708 100644 --- a/src/RedisCachePool.php +++ b/src/RedisCachePool.php @@ -38,7 +38,11 @@ public function __construct(\Redis $cache) protected function fetchObjectFromCache($key) { - return unserialize($this->cache->get($this->getHierarchyKey($key))); + if (false === $result = unserialize($this->cache->get($this->getHierarchyKey($key)))) { + return [false, null]; + } + + return $result; } protected function clearAllObjectsFromCache() @@ -59,11 +63,12 @@ protected function clearOneObjectFromCache($key) protected function storeItemInCache($key, CacheItemInterface $item, $ttl) { $key = $this->getHierarchyKey($key); + $data = serialize([true, $item->get()]); if ($ttl === null) { - return $this->cache->set($key, serialize($item)); + return $this->cache->set($key, $data); } - return $this->cache->setex($key, $ttl, serialize($item)); + return $this->cache->setex($key, $ttl, $data); } protected function getValueFormStore($key) From 8dc38634a7b3d133a2b8cede3079e00986db4dfb Mon Sep 17 00:00:00 2001 From: Aaron Scherer Date: Mon, 18 Jan 2016 12:42:13 -0800 Subject: [PATCH 2/3] Updating adapter-common dep --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c10f5bf..7437460 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ "php": "^5.5|^7.0", "ext-redis": "*", "psr/cache": "1.0.0", - "cache/adapter-common": "^0.1.2", + "cache/adapter-common": "^0.2", "cache/taggable-cache": "^0.3", "cache/hierarchical-cache": "^0.1" }, From ee0dd330eea1772f23d1528d88bc3b9dfc4a3aac Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Tue, 19 Jan 2016 20:49:31 +0100 Subject: [PATCH 3/3] Style and fix version for test --- composer.json | 4 ++-- src/RedisCachePool.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 7437460..f55de9f 100644 --- a/composer.json +++ b/composer.json @@ -33,12 +33,12 @@ "psr/cache": "1.0.0", "cache/adapter-common": "^0.2", "cache/taggable-cache": "^0.3", - "cache/hierarchical-cache": "^0.1" + "cache/hierarchical-cache": "^0.2" }, "require-dev": { "phpunit/phpunit": "^5.1|^4.0", - "cache/integration-tests": "dev-master" + "cache/integration-tests": "^0.7" }, "provide": { diff --git a/src/RedisCachePool.php b/src/RedisCachePool.php index 55fe708..d412897 100644 --- a/src/RedisCachePool.php +++ b/src/RedisCachePool.php @@ -39,7 +39,7 @@ public function __construct(\Redis $cache) protected function fetchObjectFromCache($key) { if (false === $result = unserialize($this->cache->get($this->getHierarchyKey($key)))) { - return [false, null]; + return [false, null]; } return $result; @@ -62,7 +62,7 @@ protected function clearOneObjectFromCache($key) protected function storeItemInCache($key, CacheItemInterface $item, $ttl) { - $key = $this->getHierarchyKey($key); + $key = $this->getHierarchyKey($key); $data = serialize([true, $item->get()]); if ($ttl === null) { return $this->cache->set($key, $data);