jekeyhui99 发表于 2018-12-18 09:46:29

Thinkphp关闭缓存方法总结

<span style="color: rgb(50, 50, 50); font-family: &quot;Century Gothic&quot;, &quot;Microsoft yahei&quot;;">ThinkPHP在数据缓存方面包括文件方式、共享内存方式和数据库方式在内的多种方式进行缓存,通过插件方式还可以增加以后需要的缓存类,让应用开发可以选择更加适合自己的缓存方式,从而有效地提高应用执行效率。目前已经支持的缓存方式包括:File、Apachenote、Apc、Eaccelerator、Memcache、Shmop、Sqlite、Db、Redis和Xcache。</span><br style="color: rgb(50, 50, 50); font-family: &quot;Century Gothic&quot;, &quot;Microsoft yahei&quot;;"><span style="color: rgb(50, 50, 50); font-family: &quot;Century Gothic&quot;, &quot;Microsoft yahei&quot;;">更多详细内容请查看:http://www.111cn.net/phper/thinkPhp/45890.htm</span><br style="color: rgb(50, 50, 50); font-family: &quot;Century Gothic&quot;, &quot;Microsoft yahei&quot;;"><span style="color: rgb(50, 50, 50); font-family: &quot;Century Gothic&quot;, &quot;Microsoft yahei&quot;;">为了开发的方便,可以把缓存给去除。</span><br style="color: rgb(50, 50, 50); font-family: &quot;Century Gothic&quot;, &quot;Microsoft yahei&quot;;"><br style="color: rgb(50, 50, 50); font-family: &quot;Century Gothic&quot;, &quot;Microsoft yahei&quot;;"><span style="color: rgb(50, 50, 50); font-family: &quot;Century Gothic&quot;, &quot;Microsoft yahei&quot;;">1.找到ThinkPHPCommonconvention.php和ThinkPHPCommondebug.php</span><br style="color: rgb(50, 50, 50); font-family: &quot;Century Gothic&quot;, &quot;Microsoft yahei&quot;;"><br style="color: rgb(50, 50, 50); font-family: &quot;Century Gothic&quot;, &quot;Microsoft yahei&quot;;"><span style="color: rgb(50, 50, 50); font-family: &quot;Century Gothic&quot;, &quot;Microsoft yahei&quot;;">2.打开这两个文件找到你想要的设置即可。</span><br style="color: rgb(50, 50, 50); font-family: &quot;Century Gothic&quot;, &quot;Microsoft yahei&quot;;"><br style="color: rgb(50, 50, 50); font-family: &quot;Century Gothic&quot;, &quot;Microsoft yahei&quot;;"><span style="color: rgb(50, 50, 50); font-family: &quot;Century Gothic&quot;, &quot;Microsoft yahei&quot;;">debug.php中</span><code class="prettyprint linenums lang-php prettyprinted" style="position: relative; border: 1px solid rgb(209, 215, 220); padding: 2px; font-size: 14px; display: block; font-family: Consolas, &quot;Liberation Mono&quot;, Courier, monospace, 微软雅黑; margin-top: 10px; margin-bottom: 10px; color: rgb(50, 50, 50);"><ol class="linenums" style="margin-left: 40px; color: rgb(43, 165, 216); list-style-position: outside; list-style-image: initial;"><li class="L0" style="margin-left: 0px; padding-right: 5px; padding-left: 5px; border-left: 1px solid rgb(209, 215, 220); line-height: 23px; background-color: rgb(250, 250, 250);"><span class="str" style="color: rgb(0, 136, 0);">'TMPL_CACHE_ON'</span><span class="pun" style="color: rgb(102, 102, 0);">=&gt;</span><span class="kwd" style="color: rgb(0, 0, 136);">false</span><span class="pun" style="color: rgb(102, 102, 0);">,</span><span class="pln" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="com" style="color: rgb(136, 0, 0);">//&nbsp;默认开启模板缓存</span></li><li class="L1" style="margin-left: 0px; padding-right: 5px; padding-left: 5px; border-left: 1px solid rgb(209, 215, 220); line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">&nbsp;</span></li></ol><div class="think-copy" style="position: absolute; top: -1px; right: -1px; width: 80px; height: 27px; line-height: 27px; text-align: center; border: 1px solid rgb(204, 204, 204);"><span style="display: inline-block; width: 80px; height: 27px;">复制代码</span></div><div class="zclip" id="zclip-ZeroClipboardMovie_1" style="position: absolute; left: 605px; top: -1px; width: 82px; height: 29px; z-index: 99;"></div></code><span style="color: rgb(50, 50, 50); font-family: &quot;Century Gothic&quot;, &quot;Microsoft yahei&quot;;">convention.php中'</span><code class="prettyprint linenums lang-php prettyprinted" style="position: relative; border: 1px solid rgb(209, 215, 220); padding: 2px; font-size: 14px; display: block; font-family: Consolas, &quot;Liberation Mono&quot;, Courier, monospace, 微软雅黑; margin-top: 10px; margin-bottom: 10px; color: rgb(50, 50, 50);"><ol class="linenums" style="margin-left: 40px; color: rgb(43, 165, 216); list-style-position: outside; list-style-image: initial;"><li class="L0" style="margin-left: 0px; padding-right: 5px; padding-left: 5px; border-left: 1px solid rgb(209, 215, 220); line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">TMPL_CACHE_ON</span><span class="str" style="color: rgb(0, 136, 0);">'&nbsp;&nbsp;&nbsp;=&gt;&nbsp;false,&nbsp;&nbsp;//&nbsp;默认开启模板编译缓存&nbsp;false&nbsp;的话每次都重新编译模板</span></li><li class="L1" style="margin-left: 0px; padding-right: 5px; padding-left: 5px; border-left: 1px solid rgb(209, 215, 220); line-height: 23px; background-color: rgb(250, 250, 250);"><span class="str" style="color: rgb(0, 136, 0);">&nbsp;</span></li><li class="L2" style="margin-left: 0px; padding-right: 5px; padding-left: 5px; border-left: 1px solid rgb(209, 215, 220); line-height: 23px; background-color: rgb(250, 250, 250);"><span class="str" style="color: rgb(0, 136, 0);">'</span><span class="pln" style="color: rgb(0, 0, 0);">ACTION_CACHE_ON</span><span class="str" style="color: rgb(0, 136, 0);">'&nbsp;&nbsp;=&gt;&nbsp;false,&nbsp;&nbsp;//&nbsp;默认关闭Action&nbsp;缓存</span></li><li class="L3" style="margin-left: 0px; padding-right: 5px; padding-left: 5px; border-left: 1px solid rgb(209, 215, 220); line-height: 23px; background-color: rgb(250, 250, 250);"><span class="str" style="color: rgb(0, 136, 0);">&nbsp;</span></li><li class="L4" style="margin-left: 0px; padding-right: 5px; padding-left: 5px; border-left: 1px solid rgb(209, 215, 220); line-height: 23px; background-color: rgb(250, 250, 250);"><span class="str" style="color: rgb(0, 136, 0);">'</span><span class="pln" style="color: rgb(0, 0, 0);">HTML_CACHE_ON</span><span class="str" style="color: rgb(0, 136, 0);">'&nbsp;&nbsp;&nbsp;=&gt;&nbsp;false,&nbsp;&nbsp;&nbsp;//&nbsp;默认关闭静态缓存</span></li><li class="L5" style="margin-left: 0px; padding-right: 5px; padding-left: 5px; border-left: 1px solid rgb(209, 215, 220); line-height: 23px; background-color: rgb(250, 250, 250);"><span class="str" style="color: rgb(0, 136, 0);">&nbsp;</span></li></ol><div class="think-copy" style="position: absolute; top: -1px; right: -1px; width: 80px; height: 27px; line-height: 27px; text-align: center; border: 1px solid rgb(204, 204, 204);"><span style="display: inline-block; width: 80px; height: 27px;">复制代码</span></div><div class="zclip" id="zclip-ZeroClipboardMovie_2" style="position: absolute; left: 605px; top: -1px; width: 82px; height: 29px; z-index: 99;"></div></code><span style="color: rgb(50, 50, 50); font-family: &quot;Century Gothic&quot;, &quot;Microsoft yahei&quot;;">thinkphp 怎么关闭全部缓存?(</span><code class="prettyprint linenums lang-php prettyprinted" style="position: relative; border: 1px solid rgb(209, 215, 220); padding: 2px; font-size: 14px; display: block; font-family: Consolas, &quot;Liberation Mono&quot;, Courier, monospace, 微软雅黑; margin-top: 10px; margin-bottom: 10px; color: rgb(50, 50, 50);"><ol class="linenums" style="margin-left: 40px; color: rgb(43, 165, 216); list-style-position: outside; list-style-image: initial;"><li class="L0" style="margin-left: 0px; padding-right: 5px; padding-left: 5px; border-left: 1px solid rgb(209, 215, 220); line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">APP_DEBUG</span><span class="pun" style="color: rgb(102, 102, 0);">=&gt;</span><span class="kwd" style="color: rgb(0, 0, 136);">true</span></li><li class="L1" style="margin-left: 0px; padding-right: 5px; padding-left: 5px; border-left: 1px solid rgb(209, 215, 220); line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">&nbsp;DB_FIELD_CACHE</span><span class="pun" style="color: rgb(102, 102, 0);">=&gt;</span><span class="kwd" style="color: rgb(0, 0, 136);">false</span></li><li class="L2" style="margin-left: 0px; padding-right: 5px; padding-left: 5px; border-left: 1px solid rgb(209, 215, 220); line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">&nbsp;HTML_CACHE_ON</span><span class="pun" style="color: rgb(102, 102, 0);">=&gt;</span><span class="kwd" style="color: rgb(0, 0, 136);">false</span></li><li class="L3" style="margin-left: 0px; padding-right: 5px; padding-left: 5px; border-left: 1px solid rgb(209, 215, 220); line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">&nbsp;</span></li></ol><div class="think-copy" style="position: absolute; top: -1px; right: -1px; width: 80px; height: 27px; line-height: 27px; text-align: center; border: 1px solid rgb(204, 204, 204);"><span style="display: inline-block; width: 80px; height: 27px;">复制代码</span></div><div class="zclip" id="zclip-ZeroClipboardMovie_3" style="position: absolute; left: 605px; top: -1px; width: 82px; height: 29px; z-index: 99;"></div></code><span style="color: rgb(50, 50, 50); font-family: &quot;Century Gothic&quot;, &quot;Microsoft yahei&quot;;">关闭ThinkPHP模板缓存</span><br style="color: rgb(50, 50, 50); font-family: &quot;Century Gothic&quot;, &quot;Microsoft yahei&quot;;"><br style="color: rgb(50, 50, 50); font-family: &quot;Century Gothic&quot;, &quot;Microsoft yahei&quot;;"><br style="color: rgb(50, 50, 50); font-family: &quot;Century Gothic&quot;, &quot;Microsoft yahei&quot;;"><span style="color: rgb(50, 50, 50); font-family: &quot;Century Gothic&quot;, &quot;Microsoft yahei&quot;;">最后自己找见了,在config.php里面加上一句</span><code class="prettyprint linenums lang-php prettyprinted" style="position: relative; border: 1px solid rgb(209, 215, 220); padding: 2px; font-size: 14px; display: block; font-family: Consolas, &quot;Liberation Mono&quot;, Courier, monospace, 微软雅黑; margin-top: 10px; margin-bottom: 10px; color: rgb(50, 50, 50);"><ol class="linenums" style="margin-left: 40px; color: rgb(43, 165, 216); list-style-position: outside; list-style-image: initial;"><li class="L0" style="margin-left: 0px; padding-right: 5px; padding-left: 5px; border-left: 1px solid rgb(209, 215, 220); line-height: 23px; background-color: rgb(250, 250, 250);"><span class="str" style="color: rgb(0, 136, 0);">'TMPL_CACHE_ON'</span><span class="pln" style="color: rgb(0, 0, 0);">&nbsp;</span><span class="pun" style="color: rgb(102, 102, 0);">=&gt;</span><span class="pln" style="color: rgb(0, 0, 0);">&nbsp;</span><span class="kwd" style="color: rgb(0, 0, 136);">false</span><span class="pun" style="color: rgb(102, 102, 0);">,</span></li><li class="L1" style="margin-left: 0px; padding-right: 5px; padding-left: 5px; border-left: 1px solid rgb(209, 215, 220); line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">&nbsp;</span><span class="str" style="color: rgb(0, 136, 0);">'TMPL_CACHE_ON'</span><span class="pln" style="color: rgb(0, 0, 0);">&nbsp;</span><span class="pun" style="color: rgb(102, 102, 0);">=&gt;</span><span class="pln" style="color: rgb(0, 0, 0);">&nbsp;</span><span class="kwd" style="color: rgb(0, 0, 136);">false</span><span class="pun" style="color: rgb(102, 102, 0);">,</span></li><li class="L2" style="margin-left: 0px; padding-right: 5px; padding-left: 5px; border-left: 1px solid rgb(209, 215, 220); line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">&nbsp;</span></li></ol><div class="think-copy" style="position: absolute; top: -1px; right: -1px; width: 80px; height: 27px; line-height: 27px; text-align: center; border: 1px solid rgb(204, 204, 204);"><span style="display: inline-block; width: 80px; height: 27px;">复制代码</span></div><div class="zclip" id="zclip-ZeroClipboardMovie_4" style="position: absolute; left: 605px; top: -1px; width: 82px; height: 29px; z-index: 99;"></div></code><span style="color: rgb(50, 50, 50); font-family: &quot;Century Gothic&quot;, &quot;Microsoft yahei&quot;;">这样每次运行都重新生成缓存</span><p></p>

jekeyhui99 发表于 2018-12-18 11:53:41

因在开发中需要经常修改,从而要经常删除缓存,才能看到效果。所以为了开发的方便,可以把缓存给去除。1.找到\ThinkPHP\Common\convention.php和\ThinkPHP\Common\debug.php2.打开这两个文件找到你想要的设置即可。debug.php中'TMPL_CACHE_ON'=>false,      // 默认开启模板缓存convention.php中'TMPL_CACHE_ON'   => false,// 默认开启模板编译缓存 false 的话每次都重新编译模板'ACTION_CACHE_ON'=> false,// 默认关闭Action 缓存'HTML_CACHE_ON'   => false,   // 默认关闭静态缓存
thinkphp 怎么关闭全部缓存?(baidu知道的满意回答)APP_DEBUG=>trueDB_FIELD_CACHE=>falseHTML_CACHE_ON=>false
页: [1]
查看完整版本: Thinkphp关闭缓存方法总结