| @@ 249-253 (lines=5) @@ | ||
| 246 | /** |
|
| 247 | * @var ExtendedCacheItemInterface $item |
|
| 248 | */ |
|
| 249 | if (!array_key_exists($item->getKey(), $this->itemInstances)) { |
|
| 250 | $this->itemInstances[ $item->getKey() ] = $item; |
|
| 251 | } else if(spl_object_hash($item) !== spl_object_hash($this->itemInstances[ $item->getKey() ])){ |
|
| 252 | throw new \RuntimeException('Spl object hash mismatches ! You probably tried to save a detached item which has been already retrieved from cache.'); |
|
| 253 | } |
|
| 254 | ||
| 255 | /** |
|
| 256 | * @eventName CacheSaveItem |
|
| @@ 280-284 (lines=5) @@ | ||
| 277 | */ |
|
| 278 | public function saveDeferred(CacheItemInterface $item) |
|
| 279 | { |
|
| 280 | if (!array_key_exists($item->getKey(), $this->itemInstances)) { |
|
| 281 | $this->itemInstances[ $item->getKey() ] = $item; |
|
| 282 | }else if(spl_object_hash($item) !== spl_object_hash($this->itemInstances[ $item->getKey() ])){ |
|
| 283 | throw new \RuntimeException('Spl object hash mismatches ! You probably tried to save a detached item which has been already retrieved from cache.'); |
|
| 284 | } |
|
| 285 | ||
| 286 | /** |
|
| 287 | * @eventName CacheSaveDeferredItem |
|
| @@ 401-405 (lines=5) @@ | ||
| 398 | */ |
|
| 399 | public function attachItem(CacheItemInterface $item) |
|
| 400 | { |
|
| 401 | if (isset($this->itemInstances[ $item->getKey() ]) && spl_object_hash($item) !== spl_object_hash($this->itemInstances[ $item->getKey() ])) { |
|
| 402 | throw new \LogicException('The item already exists and cannot be overwritten because the Spl object hash mismatches ! You probably tried to re-attach a detached item which has been already retrieved from cache.'); |
|
| 403 | } else { |
|
| 404 | $this->itemInstances[ $item->getKey() ] = $item; |
|
| 405 | } |
|
| 406 | } |
|
| 407 | ||
| 408 | ||