缓存phpcms缓存使用总结(memcached、eaccelerator、shm)(Use summary of phpcms (memcached, eaccelerator, SHM cache))

eaccelerator  时间:2021-04-17  阅读:()

phpcms缓存使用总结(memcached、eaccelerator、 shm) Use summaryof phpcms (memcached, eaccelerator, SHM cache) A template compilation cache

Reference files include/globalfuncphp andinclude/templatefuncphp

The principle of template cache is simple if the template isfirst compiled directly compile it, if not the first is tocompile the template file ($tplfile) and template cache file($compiledtplfile) modify time if the template cache filemodification time is greater than the compiled template fileis compiled template or not compile the template to improve theprogram' s execution efficiency

Copy code

Code is as follows:

Function template ($module = phpcms $template = index){

G lobal $CONFI G;

$compiledtplf ile =

$CONFIG[templatescachedir]$module_$templatetplphp;

If ($CONFIG[templaterefresh] )

{

$tplfile =

PHPCMS_ROOT/t emp lat es/$CONFIG[defaul ttempl ate]/$module/$t emplatehtml;

If (! File_exists ($compiledtplfile) | | @f ilemtime ($tplfile) >@filemtime ($compiledtplf ile))

{

Require_once PHPCMS_ROOT/inc lude/templatefuncphp;

Template_refresh ($tplfile $compiledtplfile) ;

}

}

Return $compiledtplfile;

}

B generates static cache files in a dynamic page

Similar to the caching principle of C, the name of the filegenerated here is relatively fixed

Take the question bar module as an example

Access

This directory contains indexphp files in the current directoryto determine whether there is a file called index_cachehtml if

there is no failure period directly to include this file orPrivate Const SMART_Iwww.qushu6.comNVALID_BUFFER As dynamicLong =4 "Bad buffer (null invalid addr. . ) read after the datasaved as index_cachehtml file for the next use.

Content in file indexphp

Copy code

Code is as follows:

"PHP?

Require_once /include/commonincphp;

$lastedittime = @filemtime (index_cachehtml) ;

$lastedittime = $PHP_TIME$lastedittime;

$autoupdatetime = intval ($MOD[autoupdate] ) ;

//$MOD[autoupdate] comes from cache filedata/cache/wenba_settingphp

If (file_exists (index_cachehtml) & &

$lastedittime<$autoupdatetime)

{

Echo "include cache file"";

Include index_cachehtml;

}

Else

{

Echo "read dynamic page"";

>?

How to judge whether the file is invalid, the filedata/cache/wenba_settingphp has the following settings, wherethe value of the field AutoUpdate is the file failure time unitis seconds, in the background can be set

The file wenba_settingphp is going to come from it are installedautomatically when the various modules of the data saved to thedatabase installation generated when the cache data in theinclude/commonincphp cache_all function can also generatebackground cache settings when cache will be automaticallyupdated

Copy code

Code is as follows:

"PHP?

Return array

Higth_score = >

Anybody_score = >

Answer_give_credit = >

Vote_give_credit = >

Highscore = >

Vote_give_actor</p> <p> </p>=>white-collar workers <p> </p><p> won the imperial wizard generals </p> <p> vagabondAutoUpdate = >

Name = > a s k.

Moduledir = > Wenba

Moduledomain = >

Linkurl = > /opensource/phpcms_sp_gbk/phpcms/wenba/

) ;

>?

Include/globalfuncphp

Update module setup function

Copy code

Code is as follows:if ($is _ js) $happy = a _ js ($content) ;if ($phpcache config [] = =&amp; &amp; $cachefiledir&amp;& amp; $cachefile)

{

_ ($cachefiledir dir. ) ;give _ _ contents ($cachefile was $content) ; / /在这儿生成一个html格式的文件当下次以同样的url访问时会直接读取缓存了参见include /commonincphp中的代码这儿的代码是非常非常精典的大家好好借鉴好好模仿吧the chmod ($cachefile) .

}

/ *

向浏览器发送http header跟浏览器说此页面不缓存还告诉浏览器页面的最后修改时间

第一次访问jsphp? id =时向浏览器发送http header第二次或以

后再访问此url时由于上次已经生成了缓存所以在include /commonincphp中直接调用缓存文件了直到缓存失效后再次执行此处的动态代码此处发送的header控制缓存是相对于浏览器来说的而通过file was _ contents生成的缓存是相对于电脑硬盘来说的是不一样的_.

* /header (expires: thu jul: gmt) .header (lastmodified: gmdate (d m y h: i: s) gmt) .header (cachecontrol: nocache mustrevalidate) .header (pragma: nocache) .echo $contents.

}

$$$$$$$上面的phpcache函数中的全局变量cachef iledircachefile是从哪里来的呢从这儿来的

文件include / commonincphp中的内容

复制代码

代码如下.if ( ! defined in _ admin)

{if ($$[dbiscache config) _ file = _ db cache.if ($phpcache config [] = =)

{

$$$$$$$cachef ileid = r (p _ self? php_ $querystring.phpcms _ cachefi ledir = $root / data / phpcache / substr($cachefileid) .

$$$$$$$$cachefiledir cachefile cachefileidhtml.

/ / / / / / / / (cachefile: $cachefile ";if f ile exists ($cachefile _) & amp; & amp; (p _ time < @filemtime ($cachefile) + $phpcacheexpires config [] )

{this cachefile $;exit.

}

}if (p _ querystring & amp; & amp; preg match (_ ^ (*) (htm |

html | shtm | shtml) $$$"or _ querystring urlvar)

{

_str, str_and par se (array (/) array (&amp; = $url var [] ) .}

}d数据库查询结果缓存

下面是include / commonincphp中的几行代码

复制代码

代码如下.

- $db _ _ class = db = $db (database) $_ conf ig config; / /[database]位于conf i gincphp中配置可以使用自己的数据库如mysqlsqlitesqlserver等.this _ phpcms root / include / $db _ fileclassphp.

$$$$$$$db db = new _ class.

$$$$$$$"> connect db config config dbhost] [] [] dbuser dbpwconf ig config config [dbname] $[pconnect]) .

$$$$$$$"> iscache = db config dbiscache] ; / /是否启用sqlcache (只对前台起作用建议在不生成html并且访问量过大时开启)

Gigsgigscloud($9.8)联通用户优选日本软银VPS

gigsgigsCloud日本东京软银VPS的大带宽配置有100Mbps、150Mbps和200Mbps三种,三网都走软银直连,售价最低9.8美元/月、年付98美元。gigsgigscloud带宽较大延迟低,联通用户的好选择!Gigsgigscloud 日本软银(BBTEC, SoftBank)线路,在速度/延迟/价格方面,是目前联通用户海外VPS的最佳选择,与美国VPS想比,日本软银VPS延迟更...

PhotonVPS:美国Linux VPS半价促销2.5美元/月起,可选美国洛杉矶/达拉斯/芝加哥/阿什本等四机房

photonvps怎么样?photonvps现在针对旗下美国vps推出半价促销优惠活动,2.5美元/月起,免费10Gbps DDoS防御,Linux系统,机房可选美国洛杉矶、达拉斯、芝加哥、阿什本。以前觉得老牌商家PhotonVPS贵的朋友可以先入手一个月PhotonVPS美国Linux VPS试试了。PhotonVPS允许合法大人内容,支持支付宝、paypal和信用卡,30天退款保证。Photo...

Spinservers美国圣何塞服务器$111/月流量10TB

Spinservers是Majestic Hosting Solutions,LLC旗下站点,主营美国独立服务器租用和Hybrid Dedicated等,数据中心位于美国德克萨斯州达拉斯和加利福尼亚圣何塞机房。TheServerStore.com,自 1994 年以来,它是一家成熟的企业 IT 设备供应商,专门从事二手服务器和工作站业务,在德克萨斯州拥有 40,000 平方英尺的仓库,库存中始终有...

eaccelerator为你推荐
支出127支持ipad步骤ioswin7关闭445端口win7系统怎么关闭445和135这两个端口win10关闭445端口如何进入注册表修改关闭445端口css下拉菜单如何使用HTML和CSS制作下拉菜单itunes备份itunes 里面的资料如何备份?phpecho在php中 echo和print 有什么区别win7关闭135端口如何关闭135端口,关闭它有什么影响么?迅雷下载速度迅雷下载速度真是太慢了
我的世界服务器租用 上海服务器租用 西部数码vps ddos locvps z.com wdcp 52测评网 免费mysql 免费phpmysql空间 英国伦敦 江苏双线 九零网络 第八届中美互联网论坛 cdn加速 西部主机 极域网 魔兽世界服务器维护 万根云主机 北京汽车摇号申请网站 更多