Im using CodeIgniter in a small pet-project in my spare time and missed a more granular cache than the entire page, and the code:

$cache = get_cache('that_snippet',60);
if (not $cache) {
// slow code here;
$cache = $result_of_slow_code;
write_cache('that_snippet',$cache);
}
return $cache;

is too ugly to be duplicated all over the code.

So using a little PHP hackerism (object __call() method) and extending the controller and model classes of CodeIgniter, now I can cache the methods results of controllers and models. All that you need to get cached results of myslowmethod(parameters) is call myslowmethodCached(parameters). Clean and Elegant to use, based on a ugly php hackerism, isolated in one place.

http://sergio.bruder.com.b/cachedobjects/

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

Sobre

Sergio Bruder, marido, pai, desenvolvedor Linux, nerd, cozinheiro de final de semana. Este site é minha presença web pessoal. Aqui você encontra os projetos open source pessoais e meu blog de comentários randômicos sobre o que estiver me ocupando no momento. Seja bem vindo.

RSS

http://sergio.bruder.com.br Posts RSS feed

Tag Cloud

Apple Brasil Culinária d00dz Família Finanças Hardware Literatura Nerd Sem categoria Software TV tweets Vinhos