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

Hostodo商家提供两年大流量美国VPS主机 可选拉斯维加斯和迈阿密

Hostodo商家算是一个比较小众且运营比较久的服务商,而且还是率先硬盘更换成NVMe阵列的,目前有提供拉斯维加斯和迈阿密两个机房。看到商家这两年的促销套餐方案变化还是比较大的,每个月一般有这么两次的促销方案推送,可见商家也在想着提高一些客户量。毕竟即便再老的服务商,你不走出来让大家知道,迟早会落寞。目前,Hostodo有提供两款大流量的VPS主机促销,机房可选拉斯维加斯和迈阿密两个数据中心,且都...

美国服务器20G防御 50G防御 688元CN2回国

全球领先的IDC服务商华纳云“美国服务器”正式发售啦~~~~此次上线的美国服务器包含美国云服务器、美国服务器、美国高防服务器以及美国高防云服务器。针对此次美国服务器新品上线,华纳云也推出了史无前例的超低活动力度。美国云服务器低至3折,1核1G5M低至24元/月,20G DDos防御的美国服务器低至688元/月,年付再送2个月,两年送4个月,三年送6个月,且永久续费同价,更多款高性价比配置供您选择。...

DMIT:香港国际线路vps,1.5GB内存/20GB SSD空间/4TB流量/1Gbps/KVM,$9.81/月

DMIT怎么样?DMIT是一家美国主机商,主要提供KVM VPS、独立服务器等,主要提供香港CN2、洛杉矶CN2 GIA等KVM VPS,稳定性、网络都很不错。支持中文客服,可Paypal、支付宝付款。2020年推出的香港国际线路的KVM VPS,大带宽,适合中转落地使用。现在有永久9折优惠码:July-4-Lite-10OFF,季付及以上还有折扣,非 中国路由优化;AS4134,AS4837 均...

eaccelerator为你推荐
对开展广场舞活动所产生的噪音,支持ipad支持ipad支持ipadApplicationsios5phpecho在php中 echo和print 有什么区别phpecho为什么在PHP中使用echo FALSE;什么也输出不了?应该如何输出FALSE?谢谢!fusionchartsFusionCharts连接数据库你是怎么解决的,能告诉我吗?谢谢啦联通iphone4联通iphone4合约迅雷快鸟用迅雷快鸟提示:您所在的网络暂不支持迅雷快鸟
域名系统 域名备案网站 免费动态域名解析 互联网域名管理办法 sugarhosts securitycenter adman 国外bt lighttpd 京东商城0元抢购 老左来了 服务器干什么用的 登陆空间 网购分享 永久免费空间 群英网络 可外链的相册 空间服务器 稳定空间 如何登陆阿里云邮箱 更多