Introduced getCacheEntryKey() to combine region name and cache key
This commit is contained in:
parent
dbc29d28d2
commit
34b6ce9259
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user