Created
November 21, 2011 16:35
-
-
Save mitchellhislop/1383164 to your computer and use it in GitHub Desktop.
Memcache is Magical
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$key = "News_Articles"; | |
$memcached_news_articles = $this->Controller->Memcache->get($key); | |
if(is_array($memcached_news_articles)) | |
{ | |
$news = $memcached_news_articles; | |
} | |
else | |
{ | |
$news = $Article->getNewsArticles(); | |
$this->Controller->Memcache->set($key, $news, 3600); //key, value, cache expiry length | |
} | |
//That easy. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment