Skip to content

Commit 88d48e5

Browse files
committed
Merge pull request #6 from php-cache/callable
Callable
2 parents 0bff623 + ee0dd33 commit 88d48e5

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@
3131
"php": "^5.5|^7.0",
3232
"ext-redis": "*",
3333
"psr/cache": "1.0.0",
34-
"cache/adapter-common": "^0.1.2",
34+
"cache/adapter-common": "^0.2",
3535
"cache/taggable-cache": "^0.3",
36-
"cache/hierarchical-cache": "^0.1"
36+
"cache/hierarchical-cache": "^0.2"
3737
},
3838
"require-dev":
3939
{
4040
"phpunit/phpunit": "^5.1|^4.0",
41-
"cache/integration-tests": "dev-master"
41+
"cache/integration-tests": "^0.7"
4242
},
4343
"provide":
4444
{

src/RedisCachePool.php

+9-4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ public function __construct(\Redis $cache)
3838

3939
protected function fetchObjectFromCache($key)
4040
{
41-
return unserialize($this->cache->get($this->getHierarchyKey($key)));
41+
if (false === $result = unserialize($this->cache->get($this->getHierarchyKey($key)))) {
42+
return [false, null];
43+
}
44+
45+
return $result;
4246
}
4347

4448
protected function clearAllObjectsFromCache()
@@ -58,12 +62,13 @@ protected function clearOneObjectFromCache($key)
5862

5963
protected function storeItemInCache($key, CacheItemInterface $item, $ttl)
6064
{
61-
$key = $this->getHierarchyKey($key);
65+
$key = $this->getHierarchyKey($key);
66+
$data = serialize([true, $item->get()]);
6267
if ($ttl === null) {
63-
return $this->cache->set($key, serialize($item));
68+
return $this->cache->set($key, $data);
6469
}
6570

66-
return $this->cache->setex($key, $ttl, serialize($item));
71+
return $this->cache->setex($key, $ttl, $data);
6772
}
6873

6974
protected function getValueFormStore($key)

0 commit comments

Comments
 (0)