1. Go to this page and download the library: Download tarcisiojr/php-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/ */
tarcisiojr / php-cache example snippets
class ClasseQualquer {
public function gerarNroAleatorio() {
return Cache::create(function () {
return rand(1, 100);
})
->once() // Cacheia o valor uma única vez.
->statefull() // Cache existente apenas em nivel de request.
->scope(false) // Cache do método entre instâncias.
->ttl(10) // Tempo do cache sera de 10 segundos.
->get(); // Executa a obtenção do valor
}
}
class ClasseQualquer {
public function gerarNroAleatorio() {
return Cache::create(function () {
return rand(1, 100);
})
->once() // Cacheia o valor uma única vez.
->statefull() // Cache existente apenas em nivel de request.
->scope(false) // Cache do método entre instâncias.
->ttl(10) // Tempo do cache sera de 10 segundos.
->get(); // Executa a obtenção do valor
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.