cvs: smarty /docs/fr/programmers/api-functions api-is-cached.xml
"gerald croes" <[email protected]>
| Newsgroups | gmane.comp.php.cvs.smarty |
|---|---|
| Message-ID | <cvsgerald1088791321@cvsserver> |
gerald Fri Jul 2 14:02:01 2004 EDT
Modified files:
/smarty/docs/fr/programmers/api-functions api-is-cached.xml
Log:
added $compile_id parameter
and a note about is_cached's internals
(as in en docs)
http://cvs.php.net/diff.php/smarty/docs/fr/programmers/api-functions/api-is-cached.xml?r1=1.2&r2=1.3&ty=u
Index: smarty/docs/fr/programmers/api-functions/api-is-cached.xml
diff -u smarty/docs/fr/programmers/api-functions/api-is-cached.xml:1.2 smarty/docs/fr/programmers/api-functions/api-is-cached.xml:1.3
--- smarty/docs/fr/programmers/api-functions/api-is-cached.xml:1.2 Sun May 23 11:50:38 2004
+++ smarty/docs/fr/programmers/api-functions/api-is-cached.xml Fri Jul 2 14:02:01 2004
@@ -1,50 +1,87 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
-<!-- EN-Revision: 1.1 Maintainer: nobody Status: partial -->
-<sect1 id="api.is.cached">
- <title>is_cached</title>
- <funcsynopsis>
- <funcprototype>
- <funcdef>void <function>is_cached</function></funcdef>
- <paramdef>string <parameter>template</parameter></paramdef>
- <paramdef>[string <parameter>cache_id</parameter>]</paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
+<!-- $Revision: 1.3 $ -->
+<!-- EN-Revision: 1.3 Maintainer: gerald Status: partial -->
+<refentry id="api.is.cached">
+ <refnamediv>
+ <refname>is_cached</refname>
+ <refpurpose></refpurpose>
+ </refnamediv>
+ <refsect1>
+ <title />
+ <methodsynopsis>
+ <type>bool</type><methodname>is_cached</methodname>
+ <methodparam><type>string</type><parameter>template</parameter></methodparam>
+ <methodparam choice="opt"><type>string</type><parameter>cache_id</parameter></methodparam>
+ <methodparam choice="opt"><type>string</type><parameter>compile_id</parameter></methodparam>
+ </methodsynopsis>
+ <para>
Retourne vrai s'il y a un fichier de cache valide pour ce template.
Cela fonctionne seulement si <link
linkend="variable.caching">caching</link> est a vrai.
- </para>
- <example>
- <title>is_cached</title>
-<programlisting>
+ </para>
+ <example>
+ <title>is_cached</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
$smarty->caching = true;
if(!$smarty->is_cached("index.tpl")) {
- // faire des requêtes base de données et assigner
- // des variables ici.
+//aucun appel à la base de donnée
}
-$smarty->display("index.tpl");</programlisting>
- </example>
- <para>
+$smarty->display("index.tpl");
+?>
+]]>
+ </programlisting>
+ </example>
+ <para>
Vous pouvez aussi passer en second paramètre un identifiant
de cache au cas oú vous voudriez plusieurs fichiers de cache
pour ce template.
- </para>
- <example>
- <title>is_cached with multiple-cache template</title>
-<programlisting>
+ </para>
+ <para>
+ Vous pouvez donner un identifiant de compilation en tant que troisième paramètre.
+ Si vous ne spécifiez pas ce paramètre, le <link linkend="variable.compile.id">$compile_id</link>
+ persistant sera utilisé.
+ </para>
+ <para>
+ Si vous voulez utiliser un identifiant de compilation sans utilisez d'identifiant de cache,
+ mettez <literal>null</literal> pour l'identifiant de cache.
+ </para>
+ <example>
+ <title>is_cached avec plusieurs templates</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
$smarty->caching = true;
-if(!$smarty->is_cached("index.tpl","FrontPage")) {
- // faire des requêtes base de données et assigner
- // des variables ici.
+if(!$smarty->is_cached("index.tpl", "FrontPage")) {
+ //appel de la base de données, assignation des variables
}
-$smarty->display("index.tpl","FrontPage");</programlisting>
- </example>
-</sect1>
+$smarty->display("index.tpl", "FrontPage");
+?>
+]]>
+ </programlisting>
+ </example>
+
+
+ <note>
+ <title>Note technique</title>
+ <para>
+ Si <literal>is_cached</literal> retourne vrai, il charge en fait le cache existant et
+ le stocke en interne. Tout appel supplémentaire à <link linkend="api.display">display()</link> ou
+ <link linkend="api.fetch">fetch()</link> retournera ce contenu stocké en interne
+ sans tenter de recharger le fichier en cache. Cela évite des problématiques d'accès concurents,
+ lorsqu'un second processus efface le cache entre l'appel de is_cached et l'appel à display dans
+ l'un de nos exemples ci-dessus. Cela signifie également que les appels à <link linkend="api.clear.cache">clear_cache()</link>
+ et les changements de paramètres du cache peuvent n'avoir aucun effet alors que <literal>is_cached</literal>
+ à retourné vrai.
+ </para>
+ </note>
+ </refsect1>
+</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
--
Smarty CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php