Skip to content

Commit 3191feb

Browse files
committed
Fixes to comply with adapter-common 0.2
1 parent fa9dbce commit 3191feb

File tree

1 file changed

+10
-21
lines changed

1 file changed

+10
-21
lines changed

src/MemcachedCachePool.php

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ public function __construct(\Memcached $cache)
4040

4141
protected function fetchObjectFromCache($key)
4242
{
43-
return $this->cache->get($this->trimKey($this->getHierarchyKey($key)));
43+
if (false === $result = unserialize($this->cache->get($this->getHierarchyKey($key)))) {
44+
return [false, null];
45+
}
46+
47+
return $result;
4448
}
4549

4650
protected function clearAllObjectsFromCache()
@@ -51,8 +55,8 @@ protected function clearAllObjectsFromCache()
5155
protected function clearOneObjectFromCache($key)
5256
{
5357
$this->commit();
54-
$key = $this->trimKey($this->getHierarchyKey($key, $path));
55-
$this->cache->increment($this->trimKey($path), 1, 0);
58+
$key = $this->getHierarchyKey($key, $path);
59+
$this->cache->increment($path, 1, 0);
5660
$this->clearHierarchyKeyCache();
5761

5862
if ($this->cache->delete($key)) {
@@ -69,28 +73,13 @@ protected function storeItemInCache($key, CacheItemInterface $item, $ttl)
6973
$ttl = 0;
7074
}
7175

72-
$key = $this->trimKey($this->getHierarchyKey($key));
76+
$key = $this->getHierarchyKey($key);
7377

74-
return $this->cache->set($key, $item, $ttl);
78+
return $this->cache->set($key, serialize([true, $item->get()]), $ttl);
7579
}
7680

7781
protected function getValueFormStore($key)
7882
{
79-
return $this->cache->get($this->trimKey($key));
80-
}
81-
82-
/**
83-
* Calculate a key. If it is more than 250 chars we should hash the key.
84-
*
85-
* @param $key
86-
* @param null $ref
87-
*/
88-
private function trimKey($key)
89-
{
90-
if (strlen($key) < 250) {
91-
return $key;
92-
}
93-
// This should maybe be logged
94-
return sha1($key);
83+
return $this->cache->get($key);
9584
}
9685
}

0 commit comments

Comments
 (0)