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' );
}
/**
* Removes every cache entry in the directory.
* Note: clear() removes the files inside the directory; the directory itself is left in place.
*/
function called_on_uninstall() {
( new File_Cache( $wp_uploads['basedir'] . '/my-cache', '.cache' ) )->clear();
}
$cache = new Transient_Cache( 'my_cache' );
$cache->set( 'my_key', array( 'some', 'data' ) );
// The value can be read back via either:
$value = get_transient( 'my_cache_my_key' );
( new Transient_Cache( 'my_cache' ) )->get( 'my_key' );
// Or create an instance with no group prefix:
$cache = new Transient_Cache();
$cache->set( 'my_other_key', array( 'some', 'data' ) );
$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.