Implement a caching mechanism

This commit is contained in:
Krzysztof Płaczek
2025-05-13 18:29:51 +02:00
parent 512de51d08
commit a01174b414
21 changed files with 616 additions and 471 deletions

View File

@@ -13,12 +13,15 @@ final class DiscontinuedController extends BaseController
#[Route('/discontinued', name: 'app_discontinued')]
public function __invoke(): Response
{
if($this->cache->getItem('list_discontinued')->isHit()) {
return $this->render('productList.html.twig', ['listType' => 'discontinued']);
}
$products = Product::where('updated_at', '<', now()->format('Y-m-d'))
->orderByDesc('starred')
->orderByDesc('created_by')
->with(['currentPrice'])
->get();
return $this->render('productList.html.twig', ['products' => $products]);
return $this->render('productList.html.twig', ['products' => $products, 'listType' => 'discontinued']);
}
}