mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 10:54:27 +02:00
added $compile_id parameter
and a note about is_cached's internals (as in en docs)
This commit is contained in:
@@ -1,15 +1,19 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<!-- 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>
|
||||
<!-- 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
|
||||
@@ -17,34 +21,67 @@
|
||||
</para>
|
||||
<example>
|
||||
<title>is_cached</title>
|
||||
<programlisting>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$smarty->caching = true;
|
||||
|
||||
if(!$smarty->is_cached("index.tpl")) {
|
||||
// faire des requ<71>tes base de donn<6E>es et assigner
|
||||
// des variables ici.
|
||||
//aucun appel <20> la base de donn<6E>e
|
||||
}
|
||||
|
||||
$smarty->display("index.tpl");</programlisting>
|
||||
$smarty->display("index.tpl");
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Vous pouvez aussi passer en second param<61>tre un identifiant
|
||||
de cache au cas o<> vous voudriez plusieurs fichiers de cache
|
||||
pour ce template.
|
||||
</para>
|
||||
<para>
|
||||
Vous pouvez donner un identifiant de compilation en tant que troisi<73>me param<61>tre.
|
||||
Si vous ne sp<73>cifiez pas ce param<61>tre, le <link linkend="variable.compile.id">$compile_id</link>
|
||||
persistant sera utilis<69>.
|
||||
</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 with multiple-cache template</title>
|
||||
<programlisting>
|
||||
<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<71>tes base de donn<6E>es et assigner
|
||||
// des variables ici.
|
||||
//appel de la base de donn<6E>es, assignation des variables
|
||||
}
|
||||
|
||||
$smarty->display("index.tpl","FrontPage");</programlisting>
|
||||
$smarty->display("index.tpl", "FrontPage");
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</sect1>
|
||||
|
||||
|
||||
<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<70>mentaire <20> <link linkend="api.display">display()</link> ou
|
||||
<link linkend="api.fetch">fetch()</link> retournera ce contenu stock<63> en interne
|
||||
sans tenter de recharger le fichier en cache. Cela <20>vite des probl<62>matiques d'acc<63>s concurents,
|
||||
lorsqu'un second processus efface le cache entre l'appel de is_cached et l'appel <20> display dans
|
||||
l'un de nos exemples ci-dessus. Cela signifie <20>galement que les appels <20> <link linkend="api.clear.cache">clear_cache()</link>
|
||||
et les changements de param<61>tres du cache peuvent n'avoir aucun effet alors que <literal>is_cached</literal>
|
||||
<20> retourn<72> vrai.
|
||||
</para>
|
||||
</note>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
|
Reference in New Issue
Block a user