mirror of
				https://github.com/smarty-php/smarty.git
				synced 2025-11-04 06:11:37 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			108 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			XML
		
	
	
	
	
	
			
		
		
	
	
			108 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			XML
		
	
	
	
	
	
<?xml version="1.0" encoding="iso-8859-1"?>
 | 
						|
<!-- $Revision$ -->
 | 
						|
<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>
 | 
						|
   Este retorna true si hay un cache valido para ese template.
 | 
						|
   Esto solamente funciona si <link linkend="variable.caching">
 | 
						|
   caching</link> está asignado a true.
 | 
						|
  </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 multiples 
 | 
						|
   caches 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 identificador de cache 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>
 | 
						|
 </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
 | 
						|
-->
 |