| 
									
										
										
										
											2004-04-13 11:47:32 +00:00
										 |  |  |  | <?xml version="1.0" encoding="iso-8859-1"?> | 
					
						
							|  |  |  |  | <!-- $Revision$ --> | 
					
						
							| 
									
										
										
										
											2006-02-18 17:54:23 +00:00
										 |  |  |  | <!-- EN-Revision: 1.6 Maintainer: yannick Status: ready --> | 
					
						
							| 
									
										
										
										
											2005-12-04 21:46:10 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-12-26 17:02:12 +00:00
										 |  |  |  | <refentry id="api.is.cached"> | 
					
						
							|  |  |  |  |  <refnamediv> | 
					
						
							| 
									
										
										
										
											2005-12-04 21:46:10 +00:00
										 |  |  |  |   <refname>is_cached()</refname> | 
					
						
							|  |  |  |  |   <refpurpose>Retourne &true; s'il y a un fichier de cache valide pour ce template</refpurpose> | 
					
						
							| 
									
										
										
										
											2004-12-26 17:02:12 +00:00
										 |  |  |  |  </refnamediv> | 
					
						
							|  |  |  |  |  <refsect1> | 
					
						
							| 
									
										
										
										
											2005-12-04 21:46:10 +00:00
										 |  |  |  |   <title>Description</title> | 
					
						
							| 
									
										
										
										
											2004-12-26 17:02:12 +00:00
										 |  |  |  |   <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> | 
					
						
							| 
									
										
										
										
											2005-12-04 21:46:10 +00:00
										 |  |  |  |   Cel<65> fonctionne seulement si <link linkend="variable.caching">$caching</link> | 
					
						
							| 
									
										
										
										
											2006-02-18 17:54:23 +00:00
										 |  |  |  |   est d<>fini <20> <literal>true</literal> ; voir aussi la | 
					
						
							| 
									
										
										
										
											2005-12-04 21:46:10 +00:00
										 |  |  |  |   <link linkend="caching">section sur le cache</link>. | 
					
						
							| 
									
										
										
										
											2004-12-26 17:02:12 +00:00
										 |  |  |  |   </para> | 
					
						
							|  |  |  |  |   <example> | 
					
						
							| 
									
										
										
										
											2005-12-04 21:46:10 +00:00
										 |  |  |  |    <title>Exemple avec is_cached()</title> | 
					
						
							| 
									
										
										
										
											2004-07-02 18:02:01 +00:00
										 |  |  |  |    <programlisting role="php"> | 
					
						
							|  |  |  |  | <![CDATA[ | 
					
						
							|  |  |  |  | <?php | 
					
						
							| 
									
										
										
										
											2004-04-13 11:47:32 +00:00
										 |  |  |  | $smarty->caching = true; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-12-04 21:46:10 +00:00
										 |  |  |  | if(!$smarty->is_cached('index.tpl')) { | 
					
						
							| 
									
										
										
										
											2004-07-02 18:02:01 +00:00
										 |  |  |  | //aucun appel <20> la base de donn<6E>e | 
					
						
							| 
									
										
										
										
											2004-04-13 11:47:32 +00:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-12-04 21:46:10 +00:00
										 |  |  |  | $smarty->display('index.tpl'); | 
					
						
							| 
									
										
										
										
											2004-07-02 18:02:01 +00:00
										 |  |  |  | ?> | 
					
						
							|  |  |  |  | ]]> | 
					
						
							|  |  |  |  |    </programlisting> | 
					
						
							| 
									
										
										
										
											2004-12-26 17:02:12 +00:00
										 |  |  |  |   </example> | 
					
						
							| 
									
										
										
										
											2004-07-02 18:02:01 +00:00
										 |  |  |  |   <para> | 
					
						
							| 
									
										
										
										
											2004-12-26 17:02:12 +00:00
										 |  |  |  |    Vous pouvez aussi passer en second param<61>tre un identifiant | 
					
						
							| 
									
										
										
										
											2005-12-04 21:46:10 +00:00
										 |  |  |  |    de $cache au cas o<> vous voudriez <link linkend="caching.multiple.caches">plusieurs | 
					
						
							|  |  |  |  |     fichiers</link> de cache pour ce template. | 
					
						
							| 
									
										
										
										
											2004-07-02 18:02:01 +00:00
										 |  |  |  |   </para> | 
					
						
							|  |  |  |  |   <para> | 
					
						
							| 
									
										
										
										
											2005-12-04 21:46:10 +00:00
										 |  |  |  |    Vous pouvez donner un <link linkend="variable.compile.id">identifiant de compilation</link> | 
					
						
							| 
									
										
										
										
											2005-05-25 16:49:34 +00:00
										 |  |  |  |    en tant que troisi<73>me param<61>tre. | 
					
						
							| 
									
										
										
										
											2004-07-02 18:02:01 +00:00
										 |  |  |  |    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> | 
					
						
							| 
									
										
										
										
											2005-12-04 21:46:10 +00:00
										 |  |  |  |    Si vous ne voulez pas passer un identifiant de cache mais plut<75>t un | 
					
						
							|  |  |  |  |    <link linkend="variable.compile.id">$compile_id</link>, vous devez passer | 
					
						
							|  |  |  |  |    <literal>null</literal> en tant qu'identifiant de cache. | 
					
						
							| 
									
										
										
										
											2004-07-02 18:02:01 +00:00
										 |  |  |  |   </para> | 
					
						
							| 
									
										
										
										
											2004-12-26 17:02:12 +00:00
										 |  |  |  |   <example> | 
					
						
							| 
									
										
										
										
											2005-12-04 21:46:10 +00:00
										 |  |  |  |    <title>Exemple avec is_cached() et plusieurs templates</title> | 
					
						
							| 
									
										
										
										
											2004-07-02 18:02:01 +00:00
										 |  |  |  |    <programlisting role="php"> | 
					
						
							|  |  |  |  | <![CDATA[ | 
					
						
							|  |  |  |  | <?php | 
					
						
							| 
									
										
										
										
											2004-04-13 11:47:32 +00:00
										 |  |  |  | $smarty->caching = true; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-12-04 21:46:10 +00:00
										 |  |  |  | if(!$smarty->is_cached('index.tpl', 'FrontPage')) { | 
					
						
							| 
									
										
										
										
											2004-07-02 18:02:01 +00:00
										 |  |  |  |   //appel de la base de donn<6E>es, assignation des variables | 
					
						
							| 
									
										
										
										
											2004-04-13 11:47:32 +00:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-12-04 21:46:10 +00:00
										 |  |  |  | $smarty->display('index.tpl', 'FrontPage'); | 
					
						
							| 
									
										
										
										
											2004-07-02 18:02:01 +00:00
										 |  |  |  | ?> | 
					
						
							|  |  |  |  | ]]> | 
					
						
							|  |  |  |  |    </programlisting> | 
					
						
							| 
									
										
										
										
											2004-12-26 17:02:12 +00:00
										 |  |  |  |   </example> | 
					
						
							| 
									
										
										
										
											2005-12-04 21:46:10 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-07-02 18:02:01 +00:00
										 |  |  |  |   <note> | 
					
						
							| 
									
										
										
										
											2004-12-26 17:02:12 +00:00
										 |  |  |  |    <title>Note technique</title> | 
					
						
							|  |  |  |  |    <para> | 
					
						
							| 
									
										
										
										
											2005-12-04 21:46:10 +00:00
										 |  |  |  |     Si <literal>is_cached()</literal> retourne vrai, il charge en fait le cache existant et  | 
					
						
							| 
									
										
										
										
											2004-12-26 17:02:12 +00:00
										 |  |  |  |     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,  | 
					
						
							| 
									
										
										
										
											2005-12-04 21:46:10 +00:00
										 |  |  |  |     lorsqu'un second processus efface le cache entre l'appel de is_cached() et l'appel <20> | 
					
						
							|  |  |  |  |     <link linkend="api.display">display()</link> | 
					
						
							| 
									
										
										
										
											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  | 
					
						
							| 
									
										
										
										
											2005-12-04 21:46:10 +00:00
										 |  |  |  |     is_cached() a retourn<72> vrai. | 
					
						
							| 
									
										
										
										
											2004-12-26 17:02:12 +00:00
										 |  |  |  |    </para> | 
					
						
							| 
									
										
										
										
											2004-07-02 18:02:01 +00:00
										 |  |  |  |   </note> | 
					
						
							| 
									
										
										
										
											2005-12-04 21:46:10 +00:00
										 |  |  |  |   <para> | 
					
						
							|  |  |  |  |    Voir aussi | 
					
						
							|  |  |  |  |    <link linkend="api.clear.cache">clear_cache()</link>, | 
					
						
							|  |  |  |  |    <link linkend="api.clear.all.cache">clear_all_cache()</link> et | 
					
						
							|  |  |  |  |    la <link linkend="caching">section sur le cache</link>. | 
					
						
							|  |  |  |  |   </para> | 
					
						
							| 
									
										
										
										
											2004-12-26 17:02:12 +00:00
										 |  |  |  |  </refsect1> | 
					
						
							|  |  |  |  | </refentry> | 
					
						
							| 
									
										
										
										
											2005-05-25 16:49:34 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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 | 
					
						
							| 
									
										
										
										
											2005-05-25 16:49:34 +00:00
										 |  |  |  | --> |