<?xml version="1.0" encoding="UTF-8" ?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
  <title>Latest snippets tagged cache</title>
  <link rel="alternate" href="http://snippets.prendreuncafe.com/snippets/tagged/cache/order_by/date"></link>
  <id>http://snippets.prendreuncafe.com/snippets/tagged/cache/order_by/date</id>
  <updated>2008-05-26T15:34:00Z</updated>
  <author>
    <name>Symfony</name>
    <author_email>noreply@symfony-project.com</author_email>
  </author>
<entry>
  <title>[Symfony] Effacer partiellement le cache d'une application</title>
  <link href="http://snippets.prendreuncafe.com/snippet/94"></link>
  <updated>2008-05-26T15:34:00Z</updated>
  <id>94</id>
  <summary type="html">Toujours utile depuis un contexte d'application différent de celui visé :

[code=php]
sfToolkit::clearGlob(sfConfig::get('sf_cache_dir').'/frontend/*/all/*/templates/toto.cache');
[/code]</summary>
</entry>
<entry>
  <title>[Symfony] Utiliser sqlite pour stocker le cache des templates</title>
  <link href="http://snippets.prendreuncafe.com/snippet/77"></link>
  <updated>2008-03-17T16:21:01Z</updated>
  <id>77</id>
  <summary type="html">D'abord, s'assurer d'avoir le module `sqlite` de php5 chargé et activé :

[code]
$ sudo apt-get install php5-sqlite
$ sudo /etc/init.d/apache2 restart
[/code]

Dans le fichier `factories.yml` de l'application concernée :

[code yml]
  view_cache:
    class:                     sfSQLiteCache
    param:
      automaticCleaningFactor: 0
      database:                %SF_ROOT_DIR%/cache/cache.db
[/code]

Et voilà, maintenant les `symfony cc` se feront en un éclair.</summary>
</entry>
<entry>
  <title>[Symfony] Cacher simplement un fragment de code</title>
  <link href="http://snippets.prendreuncafe.com/snippet/56"></link>
  <updated>2007-02-11T09:25:21Z</updated>
  <id>56</id>
  <summary type="html">Cacher le résultat d'un processus coûteux pour 24h :

[code]
&lt;?php if (!cache('huge_process_of_the_death', 86400)): ?&gt;
  &lt;?php foreach ($stuff as $item): ?&gt;
    // Your amazingly huge iteration processes here
  &lt;?php endforeach; ?&gt;
  &lt;?php cache_save() ?&gt;
&lt;?php endif; ?&gt;
[/code]

Pour le cacher pour un utilisateur spécifique :

[code]
&lt;?php if (!cache('huge_process_of_the_death'.md5($user-&gt;getEmail()), 86400)): ?&gt;
  &lt;?php foreach ($stuff as $item): ?&gt;
    // Your amazingly huge iteration processes here
  &lt;?php endforeach; ?&gt;
  &lt;?php cache_save() ?&gt;
&lt;?php endif; ?&gt;
[/code]

On s'assure juste de prendre l'empreinte md5 d'un attribut unique dans la table associée ;)</summary>
</entry>
<entry>
  <title>[Symfony] Cacher un objet Propel sérialisé</title>
  <link href="http://snippets.prendreuncafe.com/snippet/43"></link>
  <updated>2007-01-17T10:26:22Z</updated>
  <id>43</id>
  <summary type="html">Peut être utile pour les gros objets couteux et utilisés souvent.

[code]
$key = md5('myPropelObjectKey');
$cache = new sfProcessCache();
if ($cache-&gt;has($key)) 
{
  $obj = unserialize($cache-&gt;get($key));
}
else
{
  $obj = Table::doSelect();
  $cache-&gt;set($key, serialize($obj))
}
[/code]</summary>
</entry>
</feed>
