Skip to content

Instantly share code, notes, and snippets.

Created January 29, 2019 23:16
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save 0GiS0/151eee3d5190a7d0b380421d246c6916 to your computer and use it in GitHub Desktop.
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Cache\Adapter\AdapterInterface;
use Symfony\Component\Routing\Annotation\Route;
class HomeController extends AbstractController
private $cache;
public function __construct(AdapterInterface $cacheClient)
$this->cache = $cacheClient;
* @Route("/", name="home")
public function index()
$itemCache = $this->cache->getItem('cached');
$cached = 'no';
if (!$itemCache->isHit()) {
} else {
$cached = $itemCache->get();
return $this->render('home/index.html.twig', [
'controller_name' => 'HomeController',
'cached' => $cached,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment