PHP code example of piotrpress / cacher

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

    

piotrpress / cacher example snippets




use PiotrPress\Cacher;

$cache = new Cacher( '.cache', 3600 );

$value = $cache->get( 'hi', function ( $arg1, $arg2 ) {
    return "$arg1 $arg2";
}, 'Hello', 'world!' );

$cache->clear( 'hi' ); // clear cache for "hi" key
$cache->clear(); // clear all cache