超碰中文网,91久久精品日日躁夜夜躁欧美,一区二区三区精品道,一区二区国产在线观看,亚洲精品中文字幕乱码一区二区,天天看片高清影视在线观看,久久99精品久久久久蜜桃,久久成人影视

VPS參考測評推薦
專注分享VPS主機優惠信息
衡天云優惠活動
熱網互聯2026年促銷活動
hostkvm優惠促銷活動
zji優惠促銷活動
QQGNET優惠促銷活動
QQGNET優惠促銷活動

如何生成phpcms v9緩存文件

主機參考:VPS測評參考推薦/專注分享VPS服務器優惠信息!若您是商家可以在本站進行投稿,查看詳情!此外我們還提供軟文收錄、PayPal代付、廣告贊助等服務,查看詳情!
我們發布的部分優惠活動文章可能存在時效性,購買時建議在本站搜索商家名稱可查看相關文章充分了解該商家!若非中文頁面可使用Edge瀏覽器同步翻譯!PayPal代付/收錄合作

如何生成phpcms v9緩存文件

phpcms v9緩存文件是如何生成的?

本文介紹了phpcms的緩存結構。

我沒有做深入的研究,但phpcms的想法有其自身的優勢,這是如此令人信服。在這里,我分享一個phpcms緩存的二合一實現方案。

/include/cache.func.php

首先,定義了phpcms的一些緩存函數。phpcms的緩存分為表緩存、模型緩存、模型字段緩存和模塊緩存。首先,這些是基于表的緩存。

開頭有一個函數。

函數cache _ all(){ @ set _ time _ limit(600);cache _ common();緩存模塊();cache _ model();cache _ category();cache _ area();cache _ type();緩存成員組();cache _ role();cache _ author();cache _ keyword();cache _ copy from();cache _ pos();cache _ status();cache _ workflow();tags _ update();返回TRUE這個函數調用很多緩存函數來生成緩存。

首先是第一個函數,cache_common。

可以看到以下注釋:寫前綴名_型號、前綴名_類別、前綴名_模塊、前綴名、前綴名_類型、前綴名_區域等。放入$CACHE數組的對應表中(例如,模型表$ CACHE【“model“】= $ arr的數據,$ arr是phpcms_model表的數據)。

函數cache _ common(){ global $ db;$ data = array();$ result = $ d B- & gt;查詢(& quot從“中選擇“模塊”、“名稱”、“路徑”、“url”、“iscore”、“版本”。DB_PRE。"模塊`其中` disabled `= 0 & quot;);while($ r = $ db-& gt;fetch _ array($ result)){ if(!$ r【& amp;#39;路徑與方法。#39;】)$ r【& amp;#39;路徑與方法。#39;】= $ r【& amp;#39;模塊與應用。#39;】= = = & amp;#39;phpcms & amp#39;?& amp#39;& amp#39;:$ r【& amp;#39;模塊與應用。#39;].& amp#39;/& amp;#39;;如果(!$ r【& amp;#39;url & amp#39;】)$ r【& amp;#39;url & amp#39;】= $ r【& amp;#39;模塊與應用。#39;】= = = & amp;#39;phpcms & amp#39;?& amp#39;& amp#39;:$ r【& amp;#39;模塊與應用。#39;].& amp#39;/& amp;#39;;$ data【$ r 【& amp;#39;模塊與應用。#39;】】= $ r;} $ d B- & gt;free _ result($ result);$ CACHE【& amp;#39;模塊與應用。#39;】= $ data//以上是將對應的模塊寫入$ CACHE$ data = array();$ result = $ d B- & gt;查詢(& quotSELECT * FROM ` & quot。DB_PRE。"模型`其中` disabled `= 0 & quot;);while($ r = $ db-& gt;fetch _ array($ result)){ $ data【$ r【& amp;#39;modelid & amp#39;】】= $ r;} $ d B- & gt;free _ result($ result);$ CACHE【& amp;#39;模特與模特。#39;】= $ data$ data = array();//以上是寫入數組$CACHE的對應模型表中的內容;$ result = $ d B- & gt;查詢(& quot請選擇“catid”、“module”、“type”、“modelid”、“catname”、“style”、“image”、“catdir”、“url”、“parentid”、“arrparentid”、“parentid”、“child”、“arrchildid”、“items”、“citems”、“pitems”、“ismenu”、“letter”FROM。DB_PRE。"類別“其中1個訂單按listorder,catid` & quot);while($ r = $ db-& gt;fetch _ array($ result))。#39;url & amp#39;】= URL($ r【& amp;#39;url & amp#39;]);$ data【$ r 【& amp;#39;catid & amp#39;】】= $ r;} $ d B- & gt;free _ result($ result);$ CACHE【& amp;#39;類別與主題。#39;】= $ data//以上是將所有列寫入$ CACHE array $ data = array();$ result = $ d B- & gt;查詢(& quot從` & quot中選擇` typeid `、` modelid `、` module `、` name `、` style `、` typedir `、` url `。DB_PRE。"鍵入“其中1 ORDER BY‘list ORDER‘,typeid` & quot);while($ r = $ db-& gt;fetch _ array($ result)){ $ data【$ r【& amp;#39;typeid & amp#39;】】= $ r;} $ d B- & gt;free _ result($ result);$ CACHE【& amp;#39;類型&amp。#39;】= $ data//以上是將類別表中的所有數據寫入$ CACHE $ data = array();$ result = $ d B- & gt;查詢(& quot從` & quot中選擇` areaid `、` name `、` style `、` parentid `、` arrparentid `、` child `、` arrchildid `。DB_PRE。"area `其中1 ORDER BY `listorder,` areaid` & quot);while($ r = $ db-& gt;fetch _ array($ result)){ $ data【$ r【& amp;#39;areaid & amp#39;】】= $ r;} $ d B- & gt;free _ result($ result);$ CACHE【& amp;#39;面積和面積。#39;】= $ data//所有區域表都寫入$ CACHE$ data = array();$ result = $ d B- & gt;查詢(& quot從“urlruleid”中選擇“urlrule”。DB_PRE。"urlrule `其中1 ORDER BY ` urlruleid `& quot;);while($ r = $ db-& gt;fetch _ array($ result)){ $ data【$ r【& amp;#39;urlruleid & amp#39;】】= $ r【& amp;#39;urlrule & amp#39;];} $ d B- & gt;free _ result($ result);$ CACHE【& amp;#39;URLRULE & amp#39;】= $ data//將所有url規則寫入緩存$ data = array();$ r = $ d B- & gt;get _ one(& quot;從“設置”中選擇“設置”。DB_PRE。"module` WHERE `module` = & amp#39;phpcms & amp#39;");$ setting = $ r【& amp;#39;設置&amp。#39;];eval(& quot;\ $ PHPCMS = $ setting");if($ PHPCMS【& amp;#39;網站鏈接& amp#39;】= = = & amp;#39;& amp#39;)$ PHPCMS【& amp;#39;網站鏈接& amp#39;】= SITE _ URL$ CACHE【& amp;#39;PHPCMS & amp#39;】= $ PHPCMS//最后,調用cache_write方法將所有數組寫入common.php location/date/date/Cache/common . PHP Cache _ write(&;#39;common.php & amp#39;,$ CACHE);返回$ CACHE}phpcms表緩存主要通過使用一個名為cache_table的函數來實現,其中$table是要緩存的表的名稱,$ files是查詢的字段名稱,默認為‘*‘,$ WHERESQL語句中的where子句,$order排序,$isline是否打開字段緩存默認情況下不打開,如果打開表字段緩存和表緩存,將同時進行。

函數cache _ table($ table,$ fields = & amp#39;* & amp#39;,$ valfield = & amp#39;& amp#39;,$ where = & amp#39;& amp#39;,$ order = & amp#39;& amp#39;,$iscacheline = 0,$ number = 0){ global $ db;$ key field = $ d B- & gt;get _ primary($ table);$ data = array();if($ where)$ where = & quot;WHERE $ where & quot;如果(!$ order)$ order = $ key field;$limit = $number?"限制0,$ number & quot:& amp#39;& amp#39;;$ result = $ d B- & gt;查詢(& quot從`$ table `$ where ORDER BY $ ORDER $ limit & quot;中選擇$fields);$ table = preg _ replace(& quot;/^"。DB_PRE。"(.*)$/& quot;,& quot",$ table);while($ r = $ db-& gt;fetch _ array($ result)){ if(isset($ r【& amp;#39;設置&amp。#39;】)& amp& amp!空的(r 【& amp;#39;設置&amp。#39;】)){ $ setting = $ r【& amp;#39;設置&amp。#39;];eval(& quot;\ $ setting = $ setting");unset(r 【& amp;#39;設置&amp。#39;]);if(is _ array(setting))$ r = array _ merge(r,$ setting);} $ key = $ r【$ key field】;$value = $valfield?$ r【$ valfield】:$ r;$ data【$ key】= $ value;if($ iscache line)cache _ write($ table。& amp#39;_ & amp#39;。$key。& amp#39;。php與#39;,$ value);//表字段緩存} $ db-& gt;free _ result($ result);cache _ write($ table。& amp#39;。php與#39;,$ data);//表緩存}將數據數組寫入對應的緩存文件。上面的函數是判斷常量CACHE_PATH是否有默認為data/cache的路徑,然后用file_put_contents將緩存的數據寫入對應的cachefile。

函數cache _ write($ file,$array,$ path = & amp#39;& amp#39;){if(!is _ array($ array))返回false$ array = & quot& lt?php \返回& quot。var _ export($ array,true)。";\n?& gt";$ cache file =($ path?$path : CACHE_PATH)。$ file$ strlen = file _ put _ contents($ cache file,$ array);@ chmod($ cache file,0777);return $ strlen}至于其他的,可以參考上面的方法添加。你可以查看相應的cache.func.php。

//緩存模型表函數cache _ model(){ cache _ table(db _ pre。&;#39;模特與模特。#39;,& amp#39;* & amp#39;,& amp#39;& amp#39;,& amp#39;& amp#39;,& amp#39;modelid & amp#39;, 1);}//緩存分類表生成的文件路徑為../data/cache category _ catid . PHP function cache _ category(){ cache _ table(db _ pre。&;#39;類別與主題。#39;,& amp#39;* & amp#39;,& amp#39;& amp#39;,& amp#39;& amp#39;,& amp#39;列表順序,catid & amp#39;, 1);}緩存類別表生成路徑

../data/cache/type _ typeid . PHP function cache _ type(){ cache _ table(DB _ PRE。& amp#39;類型&amp。#39;,& amp#39;* & amp#39;,& amp#39;& amp#39;,& amp#39;& amp#39;,& amp#39;listorder,typeid & amp#39;, 1);}//緩存區列表生成路徑:../數據/緩存/areaid.php地區。

函數cache _ area(){ cache _ table(DB _ PRE。& amp#39;面積和面積。#39;,& amp#39;* & amp#39;,& amp#39;& amp#39;,& amp#39;& amp#39;,& amp#39;listorder,areaid & amp#39;, 1);}//緩存用戶組表//生成路徑:。/data/cache member _ group NP _ group _ id . PHP function cache _ member _ group(){ cache _ table(db _ pre。&;#39;會員_團體&amp。#39;,& amp#39;* & amp#39;,& amp#39;& amp#39;,& amp#39;& amp#39;,& amp#39;groupid & amp#39;, 1);緩存表(DB_PRE。& amp#39;會員_團體&amp。#39;,& amp#39;* & amp#39;,& amp#39;姓名和名稱。#39;,& amp#39;& amp#39;,& amp#39;groupid & amp#39;, 0);}//緩存角色表//生成路徑:。/data/cache/role _ roleid . PHP function cache _ role(){ cache _ table(db _ pre。&;#39;角色與角色。#39;,& amp#39;* & amp#39;,& amp#39;姓名和名稱。#39;,& amp#39;& amp#39;,& amp#39;listorder,roleid & amp#39;);}//緩存作者表//生成路徑:。/data/cache/author _ authorized . PHP function cache _ author(){ cache _ table(db _ pre。&;#39;作者& amp#39;,& amp#39;* & amp#39;,& amp#39;姓名和名稱。#39;,& amp#39;& amp#39;,& amp#39;listorder、authorid & amp#39;, 0, 100);} function cache _ keyword(){ cache _ table(DB _ PRE。& amp#39;關鍵詞& amp#39;,& amp#39;* & amp#39;,& amp#39;標簽& amp#39;,& amp#39;& amp#39;,& amp#39;列表順序,使用時間和。#39;, 0, 100);}函數cache _ copy from(){ cache _ table(DB _ PRE。& amp#39;copyfrom & amp#39;,& amp#39;* & amp#39;,& amp#39;& amp#39;,& amp#39;& amp#39;,& amp#39;列表順序,使用時間和。#39;, 0, 100);}函數cache _ pos(){ cache _ table(DB _ PRE。& amp#39;職位和職位。#39;,& amp#39;* & amp#39;,& amp#39;姓名和名稱。#39;,& amp#39;& amp#39;,& amp#39;listorder、posid & amp#39;, 0);}PHP中文網站,很多免費的PHPCMS教程,歡迎在線學習!

這幾篇文章你可能也喜歡:

本文由主機參考刊發,轉載請注明:如何生成phpcms v9緩存文件 http://m.k2270.com/115676.html

【騰訊云】領8888元采購禮包,搶爆款云服務器 每月 9元起,個人開發者加享折上折!
打賞
轉載請注明原文鏈接:主機參考 » 如何生成phpcms v9緩存文件
主機參考僅做資料收集,不對商家任何信息及交易做信用擔保,購買前請注意風險,有交易糾紛請自行解決!請查閱:特別聲明

評論 搶沙發

評論前必須登錄!