缓存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并且访问量过大时开启)

GreenCloudVPS$20/年多国机房可选,1核@Ryzen 3950x/1GB内存/30GB NVMe/10Gbps端口月流量2TB

GreencloudVPS此次在四个机房都上线10Gbps大带宽VPS,并且全部采用AMD处理器,其中美国芝加哥机房采用Ryzen 3950x处理器,新加坡、荷兰阿姆斯特丹、美国杰克逊维尔机房采用Ryzen 3960x处理器,全部都是RAID-1 NVMe硬盘、DDR4 2666Mhz内存,GreenCloudVPS本次促销的便宜VPS最低仅需20美元/年,支持支付宝、银联和paypal。Gree...

特网云,美国独立物理服务器 Atom d525 4G 100M 40G防御 280元/月 香港站群 E3-1200V2 8G 10M 1500元/月

特网云为您提供高速、稳定、安全、弹性的云计算服务计算、存储、监控、安全,完善的云产品满足您的一切所需,深耕云计算领域10余年;我们拥有前沿的核心技术,始终致力于为政府机构、企业组织和个人开发者提供稳定、安全、可靠、高性价比的云计算产品与服务。公司名:珠海市特网科技有限公司官方网站:https://www.56dr.com特网云为您提供高速、稳定、安全、弹性的云计算服务 计算、存储、监控、安全,完善...

AkkoCloud(60元/月 ),英国伦敦CN2 1核 768 MB 内存 10 GB SSD 硬盘 600GB 流量 英国伦敦CN2 1核  1.5G  300Mbps

官方网站:https://www.akkocloud.com/AkkoCloud新品英国伦敦CN2 GIA已上线三网回程CN2 GIA 国内速度优秀.电信去程CN2 GIALooking Glass:http://lonlg.akkocloud.com/Speedtest:http://lonlg.akkocloud.com/speedtest/新品上线刚好碰上国庆节 特此放上国庆专属九折循环优惠...

eaccelerator为你推荐
昌吉市第五小学多媒体设备技术参数University163http://www.paper.edu.cn支持ipad支持ipad重庆电信网速测试如何测量网速x-router设置路由器是我的上网设置是x怎么弄google中国地图求教谷歌中国地图~手机如何使用?360chrome360Chrome 世界之窗极速浏览器 ChromePlus谷歌sbgoogle一下"SB",虽然显示的是baidu排第一,链接的不是baidu.
快速域名备案 winscp asp.net主机 gateone 2017年万圣节 河南服务器 softbank邮箱 php空间推荐 789电视 速度云 免费全能主机 亚马逊香港官网 idc查询 东莞服务器 新睿云 环聊 贵阳电信 实惠 万网注册 免费网络空间 更多