| @@ 44-59 (lines=16) @@ | ||
| 41 | /** |
|
| 42 | * {@inheritdoc} |
|
| 43 | */ |
|
| 44 | public function load($id) |
|
| 45 | { |
|
| 46 | $cacheItem = $this->cache->getItem('ez-section-' . $id); |
|
| 47 | if ($cacheItem->isHit()) { |
|
| 48 | return $cacheItem->get(); |
|
| 49 | } |
|
| 50 | ||
| 51 | $this->logger->logCall(__METHOD__, array('section' => $id)); |
|
| 52 | $section = $this->persistenceHandler->sectionHandler()->load($id); |
|
| 53 | ||
| 54 | $cacheItem->set($section); |
|
| 55 | $cacheItem->tag(['section-' . $section->id]); |
|
| 56 | $this->cache->save($cacheItem); |
|
| 57 | ||
| 58 | return $section; |
|
| 59 | } |
|
| 60 | ||
| 61 | /** |
|
| 62 | * {@inheritdoc} |
|
| @@ 74-89 (lines=16) @@ | ||
| 71 | /** |
|
| 72 | * {@inheritdoc} |
|
| 73 | */ |
|
| 74 | public function loadByIdentifier($identifier) |
|
| 75 | { |
|
| 76 | $cacheItem = $this->cache->getItem('ez-section-' . $identifier . '-by-identifier'); |
|
| 77 | if ($cacheItem->isHit()) { |
|
| 78 | return $cacheItem->get(); |
|
| 79 | } |
|
| 80 | ||
| 81 | $this->logger->logCall(__METHOD__, array('section' => $identifier)); |
|
| 82 | $section = $this->persistenceHandler->sectionHandler()->loadByIdentifier($identifier); |
|
| 83 | ||
| 84 | $cacheItem->set($section); |
|
| 85 | $cacheItem->tag(['section-' . $section->id]); |
|
| 86 | $this->cache->save($cacheItem); |
|
| 87 | ||
| 88 | return $section; |
|
| 89 | } |
|
| 90 | ||
| 91 | /** |
|
| 92 | * {@inheritdoc} |
|
| @@ 58-75 (lines=18) @@ | ||
| 55 | /** |
|
| 56 | * {@inheritdoc} |
|
| 57 | */ |
|
| 58 | public function loadById($id) |
|
| 59 | { |
|
| 60 | $cacheItem = $this->cache->getItem('ez-url-' . $id); |
|
| 61 | ||
| 62 | $url = $cacheItem->get(); |
|
| 63 | if ($cacheItem->isHit()) { |
|
| 64 | return $url; |
|
| 65 | } |
|
| 66 | ||
| 67 | $this->logger->logCall(__METHOD__, ['url' => $id]); |
|
| 68 | $url = $this->persistenceHandler->urlHandler()->loadById($id); |
|
| 69 | ||
| 70 | $cacheItem->set($url); |
|
| 71 | $cacheItem->tag(['url-' . $id]); |
|
| 72 | $this->cache->save($cacheItem); |
|
| 73 | ||
| 74 | return $url; |
|
| 75 | } |
|
| 76 | ||
| 77 | /** |
|
| 78 | * {@inheritdoc} |
|
| @@ 46-61 (lines=16) @@ | ||
| 43 | /** |
|
| 44 | * {@inheritdoc} |
|
| 45 | */ |
|
| 46 | public function load($userId) |
|
| 47 | { |
|
| 48 | $cacheItem = $this->cache->getItem("ez-user-${userId}"); |
|
| 49 | if ($cacheItem->isHit()) { |
|
| 50 | return $cacheItem->get(); |
|
| 51 | } |
|
| 52 | ||
| 53 | $this->logger->logCall(__METHOD__, array('user' => $userId)); |
|
| 54 | $user = $this->persistenceHandler->userHandler()->load($userId); |
|
| 55 | ||
| 56 | $cacheItem->set($user); |
|
| 57 | $cacheItem->tag(['content-' . $user->id, 'user-' . $user->id]); |
|
| 58 | $this->cache->save($cacheItem); |
|
| 59 | ||
| 60 | return $user; |
|
| 61 | } |
|
| 62 | ||
| 63 | /** |
|
| 64 | * {@inheritdoc} |
|
| @@ 42-61 (lines=20) @@ | ||
| 39 | /** |
|
| 40 | * {@inheritdoc} |
|
| 41 | */ |
|
| 42 | public function countUserPreferences(int $userId): int |
|
| 43 | { |
|
| 44 | $cacheItem = $this->cache->getItem('ez-user-preference-count-' . $userId); |
|
| 45 | ||
| 46 | $count = $cacheItem->get(); |
|
| 47 | if ($cacheItem->isHit()) { |
|
| 48 | return $count; |
|
| 49 | } |
|
| 50 | ||
| 51 | $this->logger->logCall(__METHOD__, [ |
|
| 52 | 'userId' => $userId, |
|
| 53 | ]); |
|
| 54 | ||
| 55 | $count = $this->persistenceHandler->userPreferenceHandler()->countUserPreferences($userId); |
|
| 56 | $cacheItem->set($count); |
|
| 57 | $cacheItem->tag(['user-preference-count-' . $userId]); |
|
| 58 | $this->cache->save($cacheItem); |
|
| 59 | ||
| 60 | return $count; |
|
| 61 | } |
|
| 62 | ||
| 63 | /** |
|
| 64 | * {@inheritdoc} |
|