mirror of
				https://github.com/smarty-php/smarty.git
				synced 2025-10-31 12:21:36 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			118 lines
		
	
	
		
			3.5 KiB
		
	
	
	
		
			XML
		
	
	
	
	
	
			
		
		
	
	
			118 lines
		
	
	
		
			3.5 KiB
		
	
	
	
		
			XML
		
	
	
	
	
	
| <?xml version="1.0" encoding="iso-8859-1"?>
 | |
| <!-- $Revision$ -->
 | |
| <refentry id="api.is.cached">
 | |
|  <refnamediv>
 | |
|   <refname>is_cached()</refname>
 | |
|   <refpurpose>Retorna true si hay cache valido para ese template</refpurpose>
 | |
|  </refnamediv>
 | |
|  <refsect1>
 | |
|   <title>Descripción </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>
 | |
|    Esto solamente funciona si <link linkend="variable.caching">
 | |
|    caching</link> está asignado a true.
 | |
|   ver también <link linkend="caching">caching section</link>.
 | |
|   </para>
 | |
|   <example>
 | |
|    <title>is_cached()</title>
 | |
|    <programlisting role="php">
 | |
| <![CDATA[
 | |
| <?php
 | |
| $smarty->caching = true;
 | |
| 
 | |
| if(!$smarty->is_cached("index.tpl")) {
 | |
| // do database calls, assign vars here
 | |
| }
 | |
| 
 | |
| $smarty->display("index.tpl");
 | |
| ?>
 | |
| ]]>
 | |
|    </programlisting>
 | |
|   </example>
 | |
|   <para>
 | |
|    Usted también puede pasar un identificador de $cache como un 
 | |
|    segundo parámetro opcional en el caso que usted quiera 
 | |
|    <link linkend="caching.multiple.caches">multiples caches</link> 
 | |
|    para el template dado.
 | |
|   </para>
 | |
|   <para>
 | |
|    Usted puede proporcionar el identidicador como un tercer parametro 
 | |
|    opcional. Si usted omite ese parametro la persistencia del  
 | |
|    <link linkend="variable.compile.id">$compile_id</link> es usada.
 | |
|   </para>
 | |
|   <para>
 | |
|    Si usted no quiere pasar el  
 | |
|    <link linkend="variable.compile.id">identificador de cache</link> 
 | |
|    solamente quiere pasar el compile id debe pasar <literal>null</literal>
 | |
|    como el identidficador de cache.
 | |
|   </para>
 | |
|   <example>
 | |
|    <title>is_cached() con templates con multiple-cache</title>
 | |
|    <programlisting role="php">
 | |
| <![CDATA[
 | |
| <?php
 | |
| $smarty->caching = true;
 | |
| 
 | |
| if(!$smarty->is_cached("index.tpl", "FrontPage")) {
 | |
|   // do database calls, assign vars here
 | |
| }
 | |
| 
 | |
| $smarty->display("index.tpl", "FrontPage");
 | |
| ?>
 | |
| ]]>
 | |
|    </programlisting>
 | |
|   </example>
 | |
| 
 | |
| 
 | |
|   <note>
 | |
|   <title>Nota técnica</title>
 | |
|   <para>
 | |
|    Si <literal>is_cached</literal> retorna true el carga actualmente 
 | |
|    la salida del cache y lo guarda internamente. cualquier subsecuente
 | |
|    llama a <link linkend="api.display">display()</link> o
 | |
|    <link linkend="api.fetch">fetch()</link> y retorna este internamente 
 | |
|    guardando la salida y no intenta volver a cargar el archivo del cache.
 | |
|    Esto previene una condicion de la carrera que puede ocurrir cuando un
 | |
|    segundo proceso limpie el cache entre las llamadas a is_cached mostradas
 | |
|    en el ejemplo de arriba. Esto significa tambien llamar al 
 | |
|    <link linkend="api.clear.cache">clear_cache()</link> y otros cambios
 | |
|    en el cache-settings que no tiene efecto despues que 
 | |
|    <literal>is_cached</literal> retorna true.
 | |
|   </para>
 | |
|   </note>
 | |
|     <para>
 | |
|     Ver también 
 | |
|     <link linkend="api.clear.cache">clear_cache()</link>,
 | |
|     <link linkend="api.clear.all.cache">clear_all_cache()</link>,
 | |
|     y 
 | |
|     <link linkend="caching">caching section</link>.
 | |
|   </para>
 | |
| 
 | |
|  </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
 | |
| -->
 |