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

哪个好Vultr搬瓦工和Vultr97%,搬瓦工和Vultr全方位比较!

搬瓦工和Vultr哪个好?搬瓦工和Vultr都是非常火爆的国外VPS,可以说是国内网友买的最多的两家,那么搬瓦工和Vultr哪个好?如果要选择VPS,首先我们要考虑成本、服务器质量以及产品的售后服务。老玩家都知道目前在国内最受欢迎的国外VPS服务商vultr和搬瓦工口碑都很不错。搬瓦工和Vultr哪个稳定?搬瓦工和Vultr哪个速度快?为了回答这些问题,本文从线路、速度、功能、售后等多方面对比这两...

青果云(59元/月)香港多线BGP云服务器 1核 1G

青果云香港CN2_GIA主机测评青果云香港多线BGP网络,接入电信CN2 GIA等优质链路,测试IP:45.251.136.1青果网络QG.NET是一家高效多云管理服务商,拥有工信部颁发的全网云计算/CDN/IDC/ISP/IP-VPN等多项资质,是CNNIC/APNIC联盟的成员之一。青果云香港CN2_GIA主机性能分享下面和大家分享下。官方网站:点击进入CPU内存系统盘数据盘宽带ip价格购买地...

Spinservers:美国圣何塞机房少量补货/双E5/64GB DDR4/2TB SSD/10Gbps端口月流量10TB/$111/月

Chia矿机,Spinservers怎么样?Spinservers好不好,Spinservers大硬盘服务器。Spinservers刚刚在美国圣何塞机房补货120台独立服务器,CPU都是双E5系列,64-512GB DDR4内存,超大SSD或NVMe存储,数量有限,机器都是预部署好的,下单即可上架,无需人工干预,有需要的朋友抓紧下单哦。Spinservers是Majestic Hosting So...

eaccelerator为你推荐
三星iphoneiexplore.exe应用程序错误iexplore.exe应用程序错误x-router思科路由器有线端无法上网,而无线段却可以,用的是PPPOE拨号上网,一开始两种方法都不可以,检查宽canvas2动漫cv井口裕香,都有哪些作品?联通版iphone4s怎么知道到苹果4s是联通版,还是移动版重庆电信宽带测速重庆电信光纤宽带网络,内外网络和电脑等设备都没发生变化的情况下,办理了从20M提速到100M业务。win7关闭135端口win7系统怎么关闭135端口?网上很多方法都不好用!ipad无法加入网络我的IPAD无法加入网络ipad无法加入网络为什么ipad无法加入网络?www.baidu.jp谁能推荐几个日本的资源网站、搜索引擎、音乐软件?
5折 美国主机代购 Hello图床 表格样式 天猫双十一秒杀 eq2 ftp教程 秒杀预告 183是联通还是移动 lol台服官网 nerds 什么是服务器托管 河南移动网 美国在线代理服务器 paypal注册教程 网通服务器 带宽租赁 shuang12 深圳域名 卡巴斯基官网下载 更多