Change return value from getItem in TransientCache

[MAILPOET-3778]
This commit is contained in:
Jan Lysý
2021-09-01 11:31:12 +02:00
committed by Veljko V
parent 04adfe6fc6
commit aec9ecbcde
2 changed files with 5 additions and 5 deletions

View File

@@ -18,7 +18,7 @@ class TransientCache {
public function getItem(string $key, int $id): ?array { public function getItem(string $key, int $id): ?array {
$items = $this->getItems($key); $items = $this->getItems($key);
return $items[$id]['item'] ?? null; return $items[$id] ?? null;
} }
public function getOldestCreatedAt(string $key): ?\DateTime { public function getOldestCreatedAt(string $key): ?\DateTime {

View File

@@ -30,7 +30,7 @@ class SubscribersCountsController {
} }
public function getSubscribersWithoutSegmentStatisticsCount(): array { public function getSubscribersWithoutSegmentStatisticsCount(): array {
$result = $this->transientCache->getItem(TransientCache::SUBSCRIBERS_STATISTICS_COUNT_KEY, 0); $result = $this->transientCache->getItem(TransientCache::SUBSCRIBERS_STATISTICS_COUNT_KEY, 0)['item'] ?? null;
if (!$result) { if (!$result) {
$result = $this->recalculateSubscribersWithoutSegmentStatisticsCache(); $result = $this->recalculateSubscribersWithoutSegmentStatisticsCache();
} }
@@ -38,7 +38,7 @@ class SubscribersCountsController {
} }
public function getSegmentStatisticsCount(SegmentEntity $segment): array { public function getSegmentStatisticsCount(SegmentEntity $segment): array {
$result = $this->transientCache->getItem(TransientCache::SUBSCRIBERS_STATISTICS_COUNT_KEY, (int)$segment->getId()); $result = $this->transientCache->getItem(TransientCache::SUBSCRIBERS_STATISTICS_COUNT_KEY, (int)$segment->getId())['item'] ?? null;
if (!$result) { if (!$result) {
$result = $this->recalculateSegmentStatisticsCache($segment); $result = $this->recalculateSegmentStatisticsCache($segment);
} }
@@ -46,7 +46,7 @@ class SubscribersCountsController {
} }
public function getSegmentGlobalStatusStatisticsCount(SegmentEntity $segment): array { public function getSegmentGlobalStatusStatisticsCount(SegmentEntity $segment): array {
$result = $this->transientCache->getItem(TransientCache::SUBSCRIBERS_GLOBAL_STATUS_STATISTICS_COUNT_KEY, (int)$segment->getId()); $result = $this->transientCache->getItem(TransientCache::SUBSCRIBERS_GLOBAL_STATUS_STATISTICS_COUNT_KEY, (int)$segment->getId())['item'] ?? null;
if (!$result) { if (!$result) {
$result = $this->recalculateSegmentGlobalStatusStatisticsCache($segment); $result = $this->recalculateSegmentGlobalStatusStatisticsCache($segment);
} }
@@ -54,7 +54,7 @@ class SubscribersCountsController {
} }
public function getSegmentStatisticsCountById(int $segmentId): array { public function getSegmentStatisticsCountById(int $segmentId): array {
$result = $this->transientCache->getItem(TransientCache::SUBSCRIBERS_STATISTICS_COUNT_KEY, $segmentId); $result = $this->transientCache->getItem(TransientCache::SUBSCRIBERS_STATISTICS_COUNT_KEY, $segmentId)['item'] ?? null;
if (!$result) { if (!$result) {
$segment = $this->segmentsRepository->findOneById($segmentId); $segment = $this->segmentsRepository->findOneById($segmentId);
if (!$segment) { if (!$segment) {