mirror of
				https://github.com/smarty-php/smarty.git
				synced 2025-10-31 04:11:37 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			107 lines
		
	
	
		
			3.3 KiB
		
	
	
	
		
			XML
		
	
	
	
	
	
			
		
		
	
	
			107 lines
		
	
	
		
			3.3 KiB
		
	
	
	
		
			XML
		
	
	
	
	
	
| <?xml version="1.0" encoding="iso-8859-1"?>
 | |
| <!-- $Revision$ -->
 | |
| <!-- EN-Revision: 1.4 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à fonctionne seulement si <link
 | |
|    linkend="variable.caching">$caching</link> est défini à <literal>true</literal>.
 | |
|   </para>
 | |
|   <example>
 | |
|    <title>Exemple avec is_cached</title>
 | |
|    <programlisting role="php">
 | |
| <![CDATA[
 | |
| <?php
 | |
| $smarty->caching = true;
 | |
| 
 | |
| if(!$smarty->is_cached("index.tpl")) {
 | |
| //aucun appel à la base de donnée
 | |
| }
 | |
| 
 | |
| $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>
 | |
|   <para>
 | |
|    Vous pouvez donner un <link linkend="variable.compile.id">identifiant de compilation</link> 
 | |
|    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>Exemple avec is_cached et plusieurs templates</title>
 | |
|    <programlisting role="php">
 | |
| <![CDATA[
 | |
| <?php
 | |
| $smarty->caching = true;
 | |
| 
 | |
| if(!$smarty->is_cached("index.tpl", "FrontPage")) {
 | |
|   //appel de la base de données, assignation des variables
 | |
| }
 | |
| 
 | |
| $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. Celà é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 
 | |
|     comme dans l'un de nos exemples ci-dessus. Celà 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 
 | |
|     is_cached a retourné vrai.
 | |
|    </para>
 | |
|   </note>
 | |
|  </refsect1>
 | |
| </refentry>
 | |
| 
 | |
| <!-- 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
 | |
| --> |