[Symfony] Cacher un objet Propel sérialisé

Peut être utile pour les gros objets couteux et utilisés souvent.

$key = md5('myPropelObjectKey');
$cache = new sfProcessCache();
if ($cache->has($key)) 
{
  $obj = unserialize($cache->get($key));
}
else
{
  $obj = Table::doSelect();
  $cache->set($key, serialize($obj))
}
by Nicolas Perriault on 2007-01-17, tagged cache  propel  symfony 
(2 comments)

Comments on this snippet

gravatar icon
#1 Thomas Dedericks on 2008-05-06 at 12:26

Salut,

si je ne me trompe pas, il y a une petite erreur dans le nom de variable à la ligne 3 : il ne faut pas utiliser $sfProcessCache, mais bien la nouvelle instance qu'on vient de créer, $cache ...

gravatar icon
#2 Nicolas Perriault on 2008-05-11 at 02:59

Bien vu, c'est corrigé, merci :)

You need to create an account or log in to post a comment or rate this snippet.