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,50 +1,87 @@
|
|||||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<!-- EN-Revision: 1.1 Maintainer: nobody Status: partial -->
|
<!-- EN-Revision: 1.3 Maintainer: gerald Status: partial -->
|
||||||
<sect1 id="api.is.cached">
|
<refentry id="api.is.cached">
|
||||||
<title>is_cached</title>
|
<refnamediv>
|
||||||
<funcsynopsis>
|
<refname>is_cached</refname>
|
||||||
<funcprototype>
|
<refpurpose></refpurpose>
|
||||||
<funcdef>void <function>is_cached</function></funcdef>
|
</refnamediv>
|
||||||
<paramdef>string <parameter>template</parameter></paramdef>
|
<refsect1>
|
||||||
<paramdef>[string <parameter>cache_id</parameter>]</paramdef>
|
<title />
|
||||||
</funcprototype>
|
<methodsynopsis>
|
||||||
</funcsynopsis>
|
<type>bool</type><methodname>is_cached</methodname>
|
||||||
<para>
|
<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.
|
Retourne vrai s'il y a un fichier de cache valide pour ce template.
|
||||||
Cela fonctionne seulement si <link
|
Cela fonctionne seulement si <link
|
||||||
linkend="variable.caching">caching</link> est a vrai.
|
linkend="variable.caching">caching</link> est a vrai.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>is_cached</title>
|
<title>is_cached</title>
|
||||||
<programlisting>
|
<programlisting role="php">
|
||||||
|
<![CDATA[
|
||||||
|
<?php
|
||||||
$smarty->caching = true;
|
$smarty->caching = true;
|
||||||
|
|
||||||
if(!$smarty->is_cached("index.tpl")) {
|
if(!$smarty->is_cached("index.tpl")) {
|
||||||
// faire des requ<71>tes base de donn<6E>es et assigner
|
//aucun appel <20> la base de donn<6E>e
|
||||||
// des variables ici.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$smarty->display("index.tpl");</programlisting>
|
$smarty->display("index.tpl");
|
||||||
</example>
|
?>
|
||||||
<para>
|
]]>
|
||||||
|
</programlisting>
|
||||||
|
</example>
|
||||||
|
<para>
|
||||||
Vous pouvez aussi passer en second param<61>tre un identifiant
|
Vous pouvez aussi passer en second param<61>tre un identifiant
|
||||||
de cache au cas o<> vous voudriez plusieurs fichiers de cache
|
de cache au cas o<> vous voudriez plusieurs fichiers de cache
|
||||||
pour ce template.
|
pour ce template.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<para>
|
||||||
<title>is_cached with multiple-cache template</title>
|
Vous pouvez donner un identifiant de compilation en tant que troisi<73>me param<61>tre.
|
||||||
<programlisting>
|
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 avec plusieurs templates</title>
|
||||||
|
<programlisting role="php">
|
||||||
|
<![CDATA[
|
||||||
|
<?php
|
||||||
$smarty->caching = true;
|
$smarty->caching = true;
|
||||||
|
|
||||||
if(!$smarty->is_cached("index.tpl","FrontPage")) {
|
if(!$smarty->is_cached("index.tpl", "FrontPage")) {
|
||||||
// faire des requ<71>tes base de donn<6E>es et assigner
|
//appel de la base de donn<6E>es, assignation des variables
|
||||||
// des variables ici.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$smarty->display("index.tpl","FrontPage");</programlisting>
|
$smarty->display("index.tpl", "FrontPage");
|
||||||
</example>
|
?>
|
||||||
</sect1>
|
]]>
|
||||||
|
</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<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
|
<!-- Keep this comment at the end of the file
|
||||||
Local variables:
|
Local variables:
|
||||||
mode: sgml
|
mode: sgml
|
||||||
|
Reference in New Issue
Block a user