diff --git a/composer.json b/composer.json index c10f5bf..f55de9f 100644 --- a/composer.json +++ b/composer.json @@ -31,14 +31,14 @@ "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" + "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 b97fb73..d412897 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() @@ -58,12 +62,13 @@ 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, 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)