mirror of
https://github.com/smarty-php/smarty.git
synced 2025-11-08 16:21:39 +01:00
132 lines
4.5 KiB
XML
132 lines
4.5 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 2972 Maintainer: takagi Status: ready -->
|
|
<!-- CREDITS: mat-sh,daichi,joe -->
|
|
<refentry id="api.is.cached">
|
|
<refnamediv>
|
|
<refname>is_cached()</refname>
|
|
<refpurpose>テンプレートが有効なキャッシュを持つ場合にtrueを返します。</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>説明</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>
|
|
|
|
<itemizedlist>
|
|
<listitem><para>
|
|
これは、<link linkend="variable.caching">
|
|
<parameter>$caching</parameter></link> が &true; の場合にのみ機能します。
|
|
<link linkend="caching">キャッシュの項</link> も参照してください。
|
|
</para></listitem>
|
|
|
|
<listitem><para>
|
|
1つのテンプレートに
|
|
<link linkend="caching.multiple.caches">複数のキャッシュ</link>
|
|
が存在する場合は、第2パラメータに
|
|
<parameter>$cache_id</parameter> を渡すことができます。
|
|
</para></listitem>
|
|
|
|
<listitem><para>
|
|
第3パラメータに
|
|
<link linkend="variable.compile.id"><parameter>$compile id</parameter></link>
|
|
を渡すを渡す事が出来ます。このパラメータを省いた時は、もし永続的な
|
|
<link linkend="variable.compile.id">
|
|
<parameter>$compile_id</parameter></link> が設定されていればそれを使用します。
|
|
</para></listitem>
|
|
|
|
<listitem><para>
|
|
<parameter>$cache_id</parameter> は渡さずに
|
|
<link linkend="variable.compile.id">
|
|
<parameter>$compile_id</parameter></link> だけを渡したい場合は、
|
|
<parameter>$cache_id</parameter> に &null; を指定します。
|
|
</para></listitem>
|
|
</itemizedlist>
|
|
|
|
<note>
|
|
<title>テクニカルノート</title>
|
|
<para>
|
|
<varname>is_cached()</varname> が &true; を返すと、
|
|
実際にはキャッシュされた出力が読み込まれ、内部に格納されます。続いてコールされる
|
|
<link linkend="api.display"><varname>display()</varname></link> または
|
|
<link linkend="api.fetch"><varname>fetch()</varname></link>
|
|
はこの内部に格納された出力を返し、キャッシュファイルを再読み込みしようとはしません。
|
|
これにより、上の例における <varname>is_cached()</varname> のコールから
|
|
<link linkend="api.display"><varname>display()</varname></link> のコールまでの間に
|
|
別のプロセスがキャッシュをクリアしてしまうといった競合を防ぐことができます。これは、
|
|
<varname>is_cached()</varname> が &true; を返した後は
|
|
<link linkend="api.clear.cache"><varname>clear_cache()</varname></link>
|
|
やその他キャッシュ設定の変更が何の影響も及ぼさないということも意味します。
|
|
</para>
|
|
</note>
|
|
|
|
<example>
|
|
<title>is_cached()</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$smarty->caching = true;
|
|
|
|
if(!$smarty->is_cached('index.tpl')) {
|
|
// ここでデータベースを呼び出し、値を割り当てます
|
|
}
|
|
|
|
$smarty->display('index.tpl');
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
|
|
<example>
|
|
<title>複数のキャッシュを使用したテンプレートにおける is_cached()</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$smarty->caching = true;
|
|
|
|
if(!$smarty->is_cached('index.tpl', 'FrontPage')) {
|
|
// ここでデータベースを呼び出し、値を割り当てます
|
|
}
|
|
|
|
$smarty->display('index.tpl', 'FrontPage');
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
|
|
|
|
<para>
|
|
<link linkend="api.clear.cache"><varname>clear_cache()</varname></link>、
|
|
<link linkend="api.clear.all.cache"><varname>clear_all_cache()</varname></link>
|
|
および
|
|
<link linkend="caching">キャッシュの項</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
|
|
-->
|
|
|