1. Go to this page and download the library: Download shieldon/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/ */
if ($cache->has('foo3')) {
echo 'foo3 exists.';
} else {
echo 'foo3 does not exist.';
}
// foo3 exists.
public function delete(string $key): bool
if ($cache->delete('foo3')) {
echo 'foo3 has been deleted successfully.';
} else {
echo 'Failed to delete key foo3.';
}
// foo3 has been deleted successfully.
if ($cache->has('foo3')) {
echo 'foo3 exists.';
} else {
echo 'foo3 does not exist.';
}
// foo3 does not exist.
public function setMultiple(iterable $values, $ttl = null): bool
if ($cache->deleteMultiple(['bar', 'bar2'])) {
echo 'bar and bar2 have been deleted successfully.';
} else {
echo 'Failed to delete keys bar or bar2.';
}
// bar and bar2 have been deleted successfully.
$example = $cache->getMultiple(['bar', 'bar2', 'bar3'], 'hello');
var_dump($example);
/*
array(3) {
["bar"]=>
string(5) "hello"
["bar2"]=>
string(5) "hello"
["bar3"]=>
string(5) "hello"
}
*/
public function clear(): bool
if ($cache->clear()) {
echo 'All cached data has been deleted successfully.';
} else {
echo 'Failed to delete the cached data.';
}
// All cached data has been deleted successfully.