PHP code example of byjg / cache-engine

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

    

byjg / cache-engine example snippets



$cache = new \ByJG\Cache\Psr16\FileSystemCacheEngine();

// And use it:
if ($cache->has('key')) {
    // Do the complex code to get the value to be cached
    $object = callComplexCode();
    
    // Save to cache
    $cache->set('key', $object);
};
$object = $cache->get('key');


$cachePool = \ByJG\Cache\Factory::createFilePool();

$cachePool = new CachePool(new FileSystemCacheEngine());


$fileCache = new \ByJG\Cache\Psr16\FileSystemCacheEngine()
$fileCache->withKeysFromContainer(new SomePsr11Implementation());

$value = $fileCache->get('my-key');