Files
smarty/docs/fr/programmers/api-functions/api-is-cached.xml

106 lines
3.3 KiB
XML
Raw Normal View History

2004-04-13 11:47:32 +00:00
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ -->
2004-12-26 17:02:12 +00:00
<!-- EN-Revision: 1.3 Maintainer: gerald Status: ready -->
<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 &true; s'il y a un fichier de cache valide pour ce template.
Cel<65> fonctionne seulement si <link
linkend="variable.caching">caching</link> est d<>fini <20> <literal>true</literal>.
</para>
<example>
<title>Exemple avec is_cached</title>
<programlisting role="php">
<![CDATA[
<?php
2004-04-13 11:47:32 +00:00
$smarty->caching = true;
if(!$smarty->is_cached("index.tpl")) {
//aucun appel <20> la base de donn<6E>e
2004-04-13 11:47:32 +00:00
}
$smarty->display("index.tpl");
?>
]]>
</programlisting>
2004-12-26 17:02:12 +00:00
</example>
<para>
2004-12-26 17:02:12 +00:00
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>
2004-12-26 17:02:12 +00:00
<example>
<title>Exemple avec is_cached et plusieurs templates</title>
<programlisting role="php">
<![CDATA[
<?php
2004-04-13 11:47:32 +00:00
$smarty->caching = true;
if(!$smarty->is_cached("index.tpl", "FrontPage")) {
//appel de la base de donn<6E>es, assignation des variables
2004-04-13 11:47:32 +00:00
}
$smarty->display("index.tpl", "FrontPage");
?>
]]>
</programlisting>
2004-12-26 17:02:12 +00:00
</example>
<note>
2004-12-26 17:02:12 +00:00
<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. Cel<65> <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
2004-12-26 21:12:45 +00:00
comme dans l'un de nos exemples ci-dessus. Cel<65> signifie <20>galement que les appels <20>
2004-12-26 17:02:12 +00:00
<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> a retourn<72> vrai.
</para>
</note>
2004-12-26 17:02:12 +00:00
</refsect1>
</refentry>
2004-04-13 11:47:32 +00:00
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
2004-05-23 15:50:53 +00:00
-->