1. Go to this page and download the library: Download onnerby/nestedcache 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/ */
onnerby / nestedcache example snippets
\Doe\NestedCache::init();
if ($cache = \Doe\NestedCache::get(['book-gallery'])) {
// Do stuff with book gallery cache
} else {
\Doe\NestedCache::start(['book-gallery']);
$newCache = 'Lots of generated data';
...
\Doe\NestedCache::end($newCache);
}
// Remove the cache
\Doe\NestedCache::invalidate(['book-gallery']);
\Doe\NestedCache::init();
if ($cache = \Doe\NestedCache::get(['book-gallery'])) {
// Do stuff with book gallery cache
} else {
\Doe\NestedCache::start(['book-gallery']);
$newCache = "";
foreach ($books as $book) {
if (!($bookOutput = \Doe\NestedCache::get(['book-listing', $book->id]))) {
$bookOutput = "book: " . $book->name . "\n";
\Doe\NestedCache::set(['book-listing', $book->id], $bookOutput);
}
$newCache .= $bookOutput;
}
\Doe\NestedCache::end($newCache);
}
// Remove the cache for a single book will also remove cache for "book-gallery" (but not for other book listings)
\Doe\NestedCache::invalidate(['book-listing', 123]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.