Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions src/Symfony/Component/Cache/Adapter/ArrayAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,11 @@ public function getItem($key)
*/
public function getItems(array $keys = array())
{
$f = $this->createCacheItem;
$items = array();
$now = time();

foreach ($keys as $key) {
$isHit = isset($this->expiries[$this->validateKey($key)]) && ($this->expiries[$key] >= $now || !$this->deleteItem($key));
$items[$key] = $f($key, $isHit ? $this->values[$key] : null, $isHit);
$this->validateKey($key);
}

return $items;
return $this->generateItems($keys);
}

/**
Expand Down Expand Up @@ -176,4 +171,15 @@ private function validateKey($key)

return $key;
}

private function generateItems(array $keys)
{
$f = $this->createCacheItem;

foreach ($keys as $key) {
$isHit = isset($this->expiries[$key]) && ($this->expiries[$key] >= time() || !$this->deleteItem($key));

yield $key => $f($key, $isHit ? $this->values[$key] : null, $isHit);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class ArrayAdapterTest extends CachePoolTest
{
protected $skippedTests = array(
'testDeferredSaveWithoutCommit' => 'Assumes a shared cache which ArrayAdapter is not.',
'testSaveWithoutExpire' => 'Assumes a shared cache which ArrayAdapter is not.',
'testDeferredExpired' => 'Failing for now, needs to be fixed.',
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class DoctrineAdapterTest extends CachePoolTest
{
protected $skippedTests = array(
'testDeferredSaveWithoutCommit' => 'Assumes a shared cache which ArrayCache is not.',
'testSaveWithoutExpire' => 'Assumes a shared cache which ArrayCache is not.',
'testDeferredExpired' => 'Failing for now, needs to be fixed.',
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class ProxyAdapterTest extends CachePoolTest
{
protected $skippedTests = array(
'testDeferredSaveWithoutCommit' => 'Assumes a shared cache which ArrayAdapter is not.',
'testSaveWithoutExpire' => 'Assumes a shared cache which ArrayAdapter is not.',
'testDeferredExpired' => 'Failing for now, needs to be fixed.',
);

Expand Down