PHP code example of webfiori / cache

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

    

webfiori / cache example snippets


Cache::set('my_item', 'Any Data');

Cache::set('my_item', 'Any Data', 3600); //Keep the item for one hour in the cache.

Cache::set('my_item', 'Any Data', 3600, true);

$data = Cache::get('my_item');

$data = Cache::get('my_item', function () {
 return 'This is a test.';
}, 3600);

$data = Cache::get('my_item', function ($p1, $p2) {
 return 'This is a test. '.$p1.' '.$p2;
 //Output: 'This is a test. Hello World'
}, 3600, ['Hello', 'World']);

Cache::has('item_key');

Cache::delete('item_key');

Cache::flush();

Cache::setEnabled(true);

Cache::setEnabled(false);

$driver = new MyCustomDriver();
Cache::setDriver($driver);