PHP code example of mesavolt / simple-cache-bundle
1. Go to this page and download the library: Download mesavolt/simple-cache-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mesavolt / simple-cache-bundle example snippets
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new Mesavolt\SimpleCacheBundle\SimpleCacheBundle(),
);
// ...
}
// ...
}
namespace App;
use Mesavolt\SimpleCache;
use Mesavolt\SimpleCacheBundle\SimpleCachePool;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;use Symfony\Component\HttpFoundation\Response;
class HomeController extends AbstractController
{
public function demo1(SimpleCache $cache): Response
{
// $cache is the cache configured with the 'default' namespace
$time = $cache->get('val', function () {
return time();
}, SimpleCache::TTL_30_MINUTES);
return $this->render('home/demo.html.twig', [
'time' => $time
]);
}
public function demo2(): Response
{
$time = $this->get('mesavolt.simple_cache.default')->get('val', function () {
return time();
}, SimpleCache::TTL_30_MINUTES);
return $this->render('home/demo.html.twig', [
'time' => $time
]);
}
public function demo3(SimpleCachePool $pool): Response
{
$time = $pool->getCache('specific')->get('val', function () {
return time();
}, SimpleCache::TTL_30_MINUTES);
return $this->render('home/demo.html.twig', [
'time' => $time
]);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.