| @@ 240-244 (lines=5) @@ | ||
| 237 | /** |
|
| 238 | * @var ExtendedCacheItemInterface $item |
|
| 239 | */ |
|
| 240 | if (!array_key_exists($item->getKey(), $this->itemInstances)) { |
|
| 241 | $this->itemInstances[ $item->getKey() ] = $item; |
|
| 242 | } else if(spl_object_hash($item) !== spl_object_hash($this->itemInstances[ $item->getKey() ])){ |
|
| 243 | throw new \RuntimeException('Spl object hash mismatches ! You probably tried to save a detached item which has been already retrieved from cache.'); |
|
| 244 | } |
|
| 245 | ||
| 246 | /** |
|
| 247 | * @eventName CacheSaveItem |
|
| @@ 271-275 (lines=5) @@ | ||
| 268 | */ |
|
| 269 | public function saveDeferred(CacheItemInterface $item) |
|
| 270 | { |
|
| 271 | if (!array_key_exists($item->getKey(), $this->itemInstances)) { |
|
| 272 | $this->itemInstances[ $item->getKey() ] = $item; |
|
| 273 | }else if(spl_object_hash($item) !== spl_object_hash($this->itemInstances[ $item->getKey() ])){ |
|
| 274 | throw new \RuntimeException('Spl object hash mismatches ! You probably tried to save a detached item which has been already retrieved from cache.'); |
|
| 275 | } |
|
| 276 | ||
| 277 | /** |
|
| 278 | * @eventName CacheSaveDeferredItem |
|
| @@ 409-413 (lines=5) @@ | ||
| 406 | */ |
|
| 407 | public function attachItem(CacheItemInterface $item) |
|
| 408 | { |
|
| 409 | if (isset($this->itemInstances[ $item->getKey() ]) && spl_object_hash($item) !== spl_object_hash($this->itemInstances[ $item->getKey() ])) { |
|
| 410 | 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.'); |
|
| 411 | } else { |
|
| 412 | $this->itemInstances[ $item->getKey() ] = $item; |
|
| 413 | } |
|
| 414 | } |
|
| 415 | ||
| 416 | ||