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

RackNerd 黑色星期五5款年付套餐

RackNerd 商家从2019年上线以来争议也是比较大的,一直低价促销很多网友都认为坚持时间不长可能会跑路。不过,目前看到RackNerd还是在坚持且这次黑五活动也有发布,且活动促销也是比较多的,不过对于我们用户来说选择这些低价服务商尽量的不要将长远项目放在上面,低价年付套餐服务商一般都是用来临时业务的。RackNerd商家这次发布黑五促销活动,一共有五款年付套餐,涉及到多个机房。最低年付的套餐...

个人网站备案流程及注意事项(内容方向和适用主机商)

如今我们还有在做个人网站吗?随着自媒体和短视频的发展和兴起,包括我们很多WEB2.0产品的延续,当然也包括个人建站市场的低迷和用户关注的不同,有些个人已经不在做网站。但是,由于我们有些朋友出于网站的爱好或者说是有些项目还是基于PC端网站的,还是有网友抱有信心的,比如我们看到有一些老牌个人网站依旧在运行,且还有新网站的出现。今天在这篇文章中谈谈有网友问关于个人网站备案的问题。这个也是前几天有他在选择...

10GBIZ(月$2.36 ), 香港和洛杉矶CN2 GIA

10GBIZ服务商经常有看到隔壁的一些博客分享内容,我翻看网站看之前有记录过一篇,只不过由于服务商是2020年新成立的所以分享内容比较谨慎。这不至今已经有将近两年的服务商而且云服务产品也比较丰富,目前有看到10GBIZ服务商有提供香港、美国洛杉矶等多机房的云服务器、独立服务器和站群服务器。其中比较吸引到我们用户的是亚洲节点的包括香港、日本等七星级网络服务。具体我们看看相关的配置和线路产品。第一、香...

eaccelerator为你推荐
甘肃省武威市人民检察院技术检验鉴定Symbolbasiertefastreport2贵州省127我研制千万亿次超级电脑支持ipad重庆电信网速测试如何测量网速google图片搜索如何用google搜索空间照片联通iphone4联通iphone4合约win7还原系统win7如何一键还原电脑系统怎么操作winrar5.0win7 64位在运行winrar安装程序时,提示winrar停止工作。
域名备案只选云聚达 老左 hostmonster diahosting koss 360抢票助手 天猫双十一抢红包 tk域名 免费smtp服务器 东莞数据中心 爱奇艺vip免费试用7天 vip购优惠 paypal注册教程 电信托管 常州联通宽带 starry 日本代理ip 申请免费空间 华为k3 万网服务器 更多