Implement a caching mechanism
This commit is contained in:
@@ -12,11 +12,15 @@ final class PromosController extends BaseController
|
||||
#[Route('/promos', name: 'app_promos')]
|
||||
public function __invoke(): Response
|
||||
{
|
||||
if($this->cache->getItem('list_promos')->isHit()) {
|
||||
return $this->render('productList.html.twig', ['listType' => 'promos']);
|
||||
}
|
||||
|
||||
$products = Product::whereHas('currentPrice', fn(Builder $query) => $query->whereColumn('price', '<', 'productStandardPrice'))
|
||||
->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' => 'promos']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user