diff --git a/lib/Doctrine/ORM/Cache/Region/DefaultMultiGetRegion.php b/lib/Doctrine/ORM/Cache/Region/DefaultMultiGetRegion.php index 39bf9c9e8..7ecf73311 100644 --- a/lib/Doctrine/ORM/Cache/Region/DefaultMultiGetRegion.php +++ b/lib/Doctrine/ORM/Cache/Region/DefaultMultiGetRegion.php @@ -57,8 +57,9 @@ class DefaultMultiGetRegion extends DefaultRegion public function getMultiple(CollectionCacheEntry $collection) { $keysToRetrieve = array(); + foreach ($collection->identifiers as $index => $key) { - $keysToRetrieve[$index] = $this->name . '_' . $key->hash; + $keysToRetrieve[$index] = $this->getCacheEntryKey($key); } $items = $this->cache->fetchMultiple($keysToRetrieve); @@ -70,6 +71,7 @@ class DefaultMultiGetRegion extends DefaultRegion foreach ($keysToRetrieve as $index => $key) { $returnableItems[$index] = $items[$key]; } + return $returnableItems; } } diff --git a/lib/Doctrine/ORM/Cache/Region/DefaultRegion.php b/lib/Doctrine/ORM/Cache/Region/DefaultRegion.php index b210a8d8d..324e27544 100644 --- a/lib/Doctrine/ORM/Cache/Region/DefaultRegion.php +++ b/lib/Doctrine/ORM/Cache/Region/DefaultRegion.php @@ -36,6 +36,8 @@ use Doctrine\ORM\Cache\Region; */ class DefaultRegion implements Region { + const REGION_KEY_SEPARATOR = '_'; + /** * @var CacheAdapter */ @@ -84,7 +86,7 @@ class DefaultRegion implements Region */ public function contains(CacheKey $key) { - return $this->cache->contains($this->name . '_' . $key->hash); + return $this->cache->contains($this->getCacheEntryKey($key)); } /** @@ -92,7 +94,7 @@ class DefaultRegion implements Region */ public function get(CacheKey $key) { - return $this->cache->fetch($this->name . '_' . $key->hash) ?: null; + return $this->cache->fetch($this->getCacheEntryKey($key)) ?: null; } /** @@ -103,7 +105,7 @@ class DefaultRegion implements Region $result = array(); foreach ($collection->identifiers as $key) { - $entry = $this->cache->fetch($this->name . '_' . $key->hash); + $entry = $this->cache->fetch($this->getCacheEntryKey($key)); if ($entry === false) { $result = null; break; @@ -115,12 +117,21 @@ class DefaultRegion implements Region return $result; } + /** + * @param CacheKey $key + * @return string + */ + protected function getCacheEntryKey(CacheKey $key) + { + return $this->name . self::REGION_KEY_SEPARATOR . $key->hash; + } + /** * {@inheritdoc} */ public function put(CacheKey $key, CacheEntry $entry, Lock $lock = null) { - return $this->cache->save($this->name . '_' . $key->hash, $entry, $this->lifetime); + return $this->cache->save($this->getCacheEntryKey($key), $entry, $this->lifetime); } /** @@ -128,7 +139,7 @@ class DefaultRegion implements Region */ public function evict(CacheKey $key) { - return $this->cache->delete($this->name . '_' . $key->hash); + return $this->cache->delete($this->getCacheEntryKey($key)); } /**