PHP code example of zodyac / cache

1. Go to this page and download the library: Download zodyac/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/ */

    

zodyac / cache example snippets


use Zodyac\Cache\Cache;
use Zodyac\Cache\Storage\ApcStorage;

$cache = new Cache(new ApcStorage());
$result = $cache->get('key');
if ($result->isMiss()) {
    $value = expensiveOperation(42);
    $cache->set('key', $value);
}

use Zodyac\Cache\Cache;
use Zodyac\Cache\DoctrineCache;
use Zodyac\Cache\Storage\ApcStorage;

$cache = new Cache(new ApcStorage());
$doctrineCache = new DoctrineCache($cache);
$value = $doctrineCache->doFetch('key');