PHP code example of seeren / cache

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

    

seeren / cache example snippets


use Seeren\Cache\Pool\StreamCacheItemPool;

$pool = new StreamCacheItemPool();

$item = $pool
    ->getItem('foo')
    ->expiresAfter(5);

if (!$item->isHit()) {
    $item->set("item data");
    $pool->save();
}

$data = $item->get();

$response = $response
    ->withHeader("ETag", $eTag)
    ->withHeader("Last-Modified", $item->last())
    ->withHeader("Cache-Control", "public, max-age=" . $timeToLive)
    ->withHeader("Expires", $item->last(true));