1. Go to this page and download the library: Download mk4u/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/ */
mk4u / cache example snippets
> [
> //extension of cache files
> 'ext' =>'cache',
> //directory where the cache will be stored, if it does not exist create it.
> 'dir' => '/cache',
> //cache lifetime in seconds (default 5 minutes.)
> 'ttl' => 300
> ]
>
// Cache driver configuration
$config = [
'ext' => 'txt', // Extension of cache files.
'dir' => '/cache', // Directory where the cache will be stored
'ttl' => 3600 // Cache lifetime in seconds.
];
// Create an instance of the file cache driver.
$cache = Mk4U\Cache\CacheFactory::create('file', $config);
// Cache driver configuration
$config = [
'ttl' => 3600 // cache lifetime in seconds (default 5 minutes.)
];
// Create an instance of the APCu cache driver.
$cache = Mk4U\Cache\CacheFactory::create('apcu', $config);
// Store the value in the cache
$cache->set('my_key', 'Hello, World!');