| Conditions | 6 |
| Paths | 18 |
| Total Lines | 30 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 28 | private function getCached(string $cacheKey, callable $getValue) |
||
| 29 | { |
||
| 30 | if (array_key_exists($cacheKey, $this->localCache)) { |
||
| 31 | return $this->localCache[$cacheKey]; |
||
| 32 | } |
||
| 33 | |||
| 34 | try { |
||
| 35 | $cacheItem = $this->cacheItemPool->getItem($cacheKey); |
||
| 36 | |||
| 37 | if ($cacheItem->isHit()) { |
||
| 38 | return $this->localCache[$cacheKey] = $cacheItem->get(); |
||
| 39 | } |
||
| 40 | } catch (CacheException $e) { |
||
| 41 | //do nothing |
||
| 42 | } |
||
| 43 | |||
| 44 | $value = $getValue(); |
||
| 45 | |||
| 46 | if (!isset($cacheItem)) { |
||
| 47 | return $this->localCache[$cacheKey] = $value; |
||
| 48 | } |
||
| 49 | |||
| 50 | try { |
||
| 51 | $cacheItem->set($value); |
||
| 52 | $this->cacheItemPool->save($cacheItem); |
||
| 53 | } catch (CacheException $e) { |
||
| 54 | // do nothing |
||
| 55 | } |
||
| 56 | |||
| 57 | return $this->localCache[$cacheKey] = $value; |
||
| 58 | } |
||
| 60 |