PHP code example of lunkkun / caching-generator

1. Go to this page and download the library: Download lunkkun/caching-generator 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/ */

    

lunkkun / caching-generator example snippets




use Lunkkun\CachingGenerator\CachingGenerator;

$generator = function () {
    foreach (range(0, 2) as $value) {
        yield $value;
    }
};
$cachingGenerator = new CachingGenerator($generator());

foreach ($cachingGenerator as $value) {
    echo $value;
}

foreach ($cachingGenerator as $value) {
    echo $value;
}