PHP code example of mrcnpdlk / psr16cache-adapter

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

    

mrcnpdlk / psr16cache-adapter example snippets


 $oInstanceCacheFile = new \phpFastCache\Helper\Psr16Adapter(
     'files',
     [
         "host"                => null, // default localhost
         "port"                => null, // default 6379
         'defaultTtl'          => 3600 * 24, // 24h
         'ignoreSymfonyNotice' => true,
     ]);
 $oInstanceLogger    = new \Monolog\Logger('name_of_my_logger');
 $oInstanceLogger->pushHandler(new \Monolog\Handler\ErrorLogHandler(
         \Monolog\Handler\ErrorLogHandler::OPERATING_SYSTEM,
         \Psr\Log\LogLevel::DEBUG
     )
 );
 
 $oCacheAdapter = new \mrcnpdlk\Psr16Cache\Adapter($oInstanceCacheFile, $oInstanceLogger);
 $oCacheAdapter->setHashSalt(['some_hash', __DIR__]);
 
 $res = $oCacheAdapter->useCache(
     function () {
         return '1';
     },
     ['key1', 'key2'],
     10
 );
 
 var_dump($res);