PHP code example of dburiy / filecacher

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

    

dburiy / filecacher example snippets


$cacher_dir = __DIR__ . '/cacher'; 
$cacher = new \Dburiy\FileCacher($cacher_dir);

$cacher->delete("key");

use Dburiy\FileCacher;
use Dburiy\PsrBridge\FileCacher as PsrCacher;

= $cacher
    ->getItem('test')
    ->expiresAfter(DateInterval::createFromDateString('1 min'))
//    ->expiresAfter(10) // seconds
//    ->expiresAt(new DateTime('2022-01-29T13:02:00', new DateTimeZone('europe/moscow')))
    ->set(['value' => time()])
;
$cacher->save($item);
//$cacher->saveDeferred($item);
//$cacher->commit();

var_dump($item->get());

if (!$item->isHit()) {
    $cacher->deleteItem('test');
}