code: public function getProducts()
      {
          $cacheKey = "products";
          if ($this->cache->hasItem($cacheKey)) {
  
              // return from cache
              $cacheItem = $this->cache->getItem($cacheKey);
              $cachedProducts = $cacheItem->get();
              return $cachedProducts;
          }
  
          $products = $this->productRepository->getProducts();
  
          // save to cache
          $cacheItem = $this->cache->getItem($cacheKey);
          $cacheItem->set($products);
  
          return $products;
      }
docs: Get all products
  
  @return Product[]
  
  @throws RepositoryException If fetching the products failed