1. Go to this page and download the library: Download prismo-smartpro/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/ */
prismo-smartpro / cache example snippets
martPRO\Technology\CacheControl;
/*
* Folder where the cache will be saved
* Cache file extension
*/
$cache = new CacheControl(__DIR__ . "/cache", "cache");
$cache->setType(CacheControl::SERIALIZE);
/*
* Creating a new cache
* Expiry in minutes
*/
$cache->set("profile=john", [
"name" => "John Walker",
"age" => 35,
"email" => "[email protected]"
], 30);
/*
* Checks if the cache exists, if it exists, return the cache, if it doesn't exist, create it using the function
*/
$withCallable = $cache->has("data", function () {
return array(
array("name" => "John Walker", "age" => 37),
array("name" => "John Samuel", "age" => 17)
);
}, 15);
var_dump($withCallable);
/*
* Search for a cached file
* If it doesn't exist, return null
* If it has already expired, return null and delete the cache
*/
$data = $cache->get("profile=john");
/*
* Delete cache
*/
$cache->delete("profile=john");
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.