Skip to content

Commit

Permalink
Merge pull request #6 from php-cache/callable
Browse files Browse the repository at this point in the history
Callable
  • Loading branch information
cryptiklemur committed Jan 19, 2016
2 parents 0bff623 + ee0dd33 commit 88d48e5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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":
{
Expand Down
13 changes: 9 additions & 4 deletions src/RedisCachePool.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand Down

0 comments on commit 88d48e5

Please sign in to comment.