Implement a caching mechanism
This commit is contained in:
1 parent
512de51d08
commit
a01174b414
21 files changed
+616
-471
No files matched your search
@@ -11,6 +11,10 @@ final class CategoryController extends BaseController
|
||||
#[Route('/category/{category}', name: 'app_category')]
|
||||
public function __invoke(string $category): Response
|
||||
{
|
||||
if($this->cache->getItem('list_category_'.$category)->isHit()) {
|
||||
return $this->render('productList.html.twig', ['listType' => 'category_'.$category]);
|
||||
}
|
||||
|
||||
$products = Product::with('price')
|
||||
->selectRaw('products.*')
|
||||
->distinct('products.id')
|
||||
@@ -19,6 +23,7 @@ final class CategoryController extends BaseController
|
||||
->orderByDesc('starred')
|
||||
->orderByDesc('created_by')
|
||||
->get();
|
||||
return $this->render('productList.html.twig', ['products' => $products]);
|
||||
|
||||
return $this->render('productList.html.twig', ['products' => $products, 'listType' => 'category_'.$category]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user