Skip to content

Instantly share code, notes, and snippets.

@mitchellhislop
Created November 21, 2011 16:35
Show Gist options
  • Save mitchellhislop/1383164 to your computer and use it in GitHub Desktop.
Save mitchellhislop/1383164 to your computer and use it in GitHub Desktop.
Memcache is Magical
<?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