PHP code example of moust / silex-cache
1. Go to this page and download the library: Download moust/silex-cache 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/ */
moust / silex-cache example snippets
$app->register(new Moust\Silex\Provider\CacheServiceProvider(), array(
'cache.options' => array(
'driver' => 'apc'
)
));
// stores a variable
$app['cache']->store('foo', 'bar');
// stores a variable with a 1 minute lifetime
$app['cache']->store('foo', 'bar', 60);
// fetch variable
echo $app['cache']->fetch('foo');
// delete variable
$app['cache']->delete('foo');
// clear all cached variables
$app['cache']->clear();
$app->register(new Moust\Silex\Provider\CacheServiceProvider(), array(
'caches.options' => array(
'apc' => array(
'driver' => 'apc'
),
'filesystem' => array(
'driver' => 'file',
'cache_dir' => './temp'
),
'memory' => array(
'driver' => 'array'
),
'memcache' => array(
'driver' => 'memcache',
'memcache' => function () {
$memcache = new \Memcache;
$memcache->connect('localhost', 11211);
return $memcache;
}
)
)
));
$app['cache']->store('foo', 'bar');
$app['caches']['apc']->store('foo', 'bar');