PHP code example of apix / simple-cache
1. Go to this page and download the library: Download apix/simple-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/ */
apix / simple-cache example snippets
use Apix\SimpleCache;
$client = new \Redis();
#$client = new \PDO('sqlite:...'); // Any supported client object e.g. Memcached, MongoClient, ...
#$client = new Cache\Files($options); // or one that implements Apix\Cache\Adapter
#$client = 'apc'; // or an adapter name (string) e.g. "APC", "Runtime"
#$client = new MyArrayObject(); // or even a plain array() or \ArrayObject.
$cache = SimpleCache\Factory::getPool($client); // without tagging support
#$cache = SimpleCache\Factory::getTaggablePool($client); // with tagging
if ( !$cache->has('wibble_id') ) {
$data = compute_slow_and_expensive_stuff();
$cache->set('wibble_id', $data);
}
return $cache->get('wibble_id');