1. Go to this page and download the library: Download mrmanchot/simple-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/ */
mrmanchot / simple-cache example snippets
use Mrmanchot\SimpleCache\SimpleCache;
che/directory/');
// Set cache
$cache->set('key', 'value');
// Get cache
$value = $cache->get('key');
// Set cache
$cache->set('key', 'value');
// Get cache, valid for 10 minutes
$value = $cache->get('key', 10);
// Storing an array
$cache->set('array_key', ['a' => 1, 'b' => 2]);
// Retrieving an array
$array = $cache->get('array_key');
// Storing an object
$object = new stdClass();
$object->property = 'value';
$cache->set('object_key', $object);
// Retrieving an object
$object = $cache->get('object_key');
// Storing a boolean
$cache->set('boolean_key', true);
// Retrieving a boolean
$boolean = $cache->get('boolean_key');
$cachedValue = $cache->get('some_key');
if ($cachedValue === null) {
// The value is not in the cache, compute/generate the value
}
// Set cache in a subdirectory
$cache->set('user/1', 'value');
// Get cache from a subdirectory
$value = $cache->get('user/1');
// Clear a specific cache item
$cache->clear('key');
// Clear all cache items in a subdirectory
$cache->clear('user/*');
// Clear all cache items
$cache->clear('*');
phpunit test/SimpleCacheTest.php
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.