PHP code example of cakephp / cache

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

    

cakephp / cache example snippets


use Cake\Cache\Cache;

// Using a short name
Cache::config('default', [
    'className' => 'File',
    'duration' => '+1 hours',
    'path' => sys_get_tmp_dir(),
    'prefix' => 'my_app_'
]);

// Using a fully namespaced name.
Cache::config('long', [
    'className' => \Cake\Cache\Engine\ApcuEngine::class,
    'duration' => '+1 week',
    'prefix' => 'my_app_'
]);

// Using a constructed object.
$object = new FileEngine($config);
Cache::config('other', $object);

$data = Cache::remember('my_cache_key', function () {
	return Service::expensiveCall();
});