PHP code example of perturbatio / cachetags
1. Go to this page and download the library: Download perturbatio/cachetags 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/ */
perturbatio / cachetags example snippets
if ( cachetagHas('super-cool-widget') ){
echo cachetagGet('super-cool-widget');
} else {
cachetagStart('super-cool-widget', 15);
echo superCoolWidgetThatTakesTooLongToGenerate();
if ( cachetagHas('other-cool-widget') ){
echo cachetagGet('other-cool-widget');
} else {
cachetagStart('other-cool-widget', 'forever'); //widget cached until something clears it, nested inside the outer cache
echo otherCoolWidgetThatTakesTooLongToGenerate();
echo cachetagEnd();
}
echo cachetagEnd();
}
//clear the cache for a specific key
cachetagClear('super-cool-widget');
if ( $otherCoolWidgetNeedsCacheInvalidated ){ //conditionally clear the
cachetagClear('other-cool-widget');
}