Cache manga list

This commit is contained in:
Timothy Warren 2017-01-16 14:14:45 -05:00
parent 5c34c92453
commit 95f768aed3
2 changed files with 17 additions and 9 deletions

View File

@ -8,7 +8,7 @@
<th>
<h3><?= $escape->html($item['title']) ?></h3>
<?php if($item['alternate_title'] != ""): ?>
<h4><?= $escape->html($item['alternate_title']) ?></h4>
<h4><?= $item['alternate_title'] ?></h4>
<?php endif ?>
</th>
<th>

View File

@ -218,17 +218,25 @@ class KitsuModel {
'sort' => '-updated_at'
]
];
$cacheItem = $this->cache->getItem($this->getHashForMethodCall($this, __METHOD__, $options));
$data = $this->getRequest('library-entries', $options);
foreach($data['data'] as $i => &$item)
if ( ! $cacheItem->isHit())
{
$item['manga'] = $data['included'][$i];
$data = $this->getRequest('library-entries', $options);
foreach($data['data'] as $i => &$item)
{
$item['manga'] = $data['included'][$i];
}
$transformed = $this->mangaListTransformer->transformCollection($data['data']);
$cacheItem->set($transformed);
$cacheItem->save();
}
$transformed = $this->mangaListTransformer->transformCollection($data['data']);
return $transformed;
return $cacheItem->get();
}
public function search(string $type, string $query): array