use phpFastCache\CacheManager;
$cache = CacheManager::Memcached();
$keyword_webpage = md5($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].$_SERVER['QUERY_STRING']);
// try to get from Cache first.
$resultsItem = $cache->getItem($keyword_webpage)
if(!$resultsItem->isHit()) {
ob_start();
/*
ALL OF YOUR CODE GO HERE
RENDER YOUR PAGE, DB QUERY, WHATEVER
*/
// GET HTML WEBPAGE
$html = ob_get_contents();
$resultsItem->set($html)->expireAfter(1800);
$cache->save($resultsItem);
}
echo $resultsItem->get();
Created
September 17, 2016 00:15
-
-
Save Geolim4/bdccc41690c48605cff1c6cb37497f9e to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think
expireAfter
should beexpiresAfter
. See: https://gist.github.com/MarcoMiltenburg/e0a1f32e85d7808bbe6c26b10c03dfea/revisions?short_path=eae8e2f#diff-eae8e2f571f6b1cf262ffbd45838a211