PHP code example of alielmajdaoui / laravel-memoize
1. Go to this page and download the library: Download alielmajdaoui/laravel-memoize 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/ */
alielmajdaoui / laravel-memoize example snippets
namespace App\Controllers;
use Aliem\Memoize\Facades\Memoize;
class MyAwesomeController extends Controller {
public function index() {
// Check if the item `iam_heavy` is memoized and return it,
// otherwise, run the \Closure and memoize the result.
$value = Memoize::remember('iam_heavy', function() {
$result = 0;
for ($i = 0; $i < 1000000; $i++) {
$result += $i * rand(1, 10);
}
return $result;
});
return response(sprintf("My memoized value: %s", $value));
}
}