1. Go to this page and download the library: Download pinkcrab/wp-psr16-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/ */
/**
* Creates the cache directory
*/
function called_on_activation(){
new File_Cache($wp_uploads['basedir'] . '/my-cache', '.cache');
}
/**
* Clears all values form the cache directory.
* Please note doesn't delete the folder.
*/
function called_on_uninstall(){
(new File_Cache($wp_uploads['basedir'] . '/my-cache', '.cache'))->clear();
}
$cache = new Transient_Cache('my_cache');
$cache->set('my_key', ['some', 'data']);
// Will create a transient which can be recalled using either;
$value = get_transient('my_cache_my_key');
(new Transient_Cache('my_cache'))->get('my_key');
// You can create an instance with no key
$cache = New Transient_Cache();
$cache->set('my_other_key', ['some', 'data']);
// Get
$value = get_transient('my_other_key');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.