PHP code example of borschphp / cache

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

    

borschphp / cache example snippets


// PSR-16 style
$cache = new Cache(new InMemoryCacheItemPool());
$cache->set('foo', 'bar');

$foo = $cahce->get('foo', 'default_value');

$cahce->delete('foo');
$cache->clear();

// PSR-6 style
$pool = new InMemoryCacheItemPool();
$pool->save(new CacheItem('foo', 'bar'));

if ($pool->hasItem('foo')) {
    $foo = $pool->getItem('foo')->get();
    
    $pool->deleteItem('foo');
}

$pool->clear();