| Conditions | 4 |
| Paths | 4 |
| Total Lines | 22 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 29 | private function getCached(string $cacheKey, callable $getValue) |
||
| 30 | { |
||
| 31 | if (\array_key_exists($cacheKey, $this->localCache)) { |
||
| 32 | return $this->localCache[$cacheKey]; |
||
| 33 | } |
||
| 34 | |||
| 35 | try { |
||
| 36 | $cacheItem = $this->cacheItemPool->getItem($cacheKey); |
||
| 37 | } catch (CacheException $e) { |
||
| 38 | return $this->localCache[$cacheKey] = $getValue(); |
||
| 39 | } |
||
| 40 | |||
| 41 | if ($cacheItem->isHit()) { |
||
| 42 | return $this->localCache[$cacheKey] = $cacheItem->get(); |
||
| 43 | } |
||
| 44 | |||
| 45 | $value = $getValue(); |
||
| 46 | |||
| 47 | $cacheItem->set($value); |
||
| 48 | $this->cacheItemPool->save($cacheItem); |
||
| 49 | |||
| 50 | return $this->localCache[$cacheKey] = $value; |
||
| 51 | } |
||
| 53 |