public function getItem($key)
{
$this->assertValidKey($key);
if (array_key_exists($key, $this->deferred)) {
/*
* In theory, we could request & change a deferred value. In the
* case of objects, we'll clone them to make sure that when the
* value for 1 item is manipulated, it doesn't affect the value of
* the one about to be stored to cache (because those objects would
* be passed by-ref without the cloning)
*/
$value = $this->deferred[$key];
$item = is_object($value) ? clone $value : $value;
/*
* Deferred items should identify as being hit, unless if expired:
* @see https://groups.google.com/forum/?fromgroups#!topic/php-fig/pxy_VYgm2sU
*/
$item->overrideIsHit(!$item->isExpired());
return $item;
}
// return a stub object - the real call to the cache store will only be
// done once we actually want to access data from this object
return new Item($key, $this->repository);
}