phpcms缓存使用总结(memcached、 eaccelerator、 shm)A template compilation cache
Reference documents 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
The code reads 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) | | @filemtime
($tplfile) > @filemtime ($compiledtplfile) )
{
Require_once PHPCMS_ROOT/inc lude/templatefuncphp;
Template_refresh ($tplfile, $compiledtplfile) ;
}
}
Return $compiledtplfile;
}
B generates static cache files within a dynamic page
Similar to the caching principle of C, the name of the filegenerated here is relatively fixed
Take the question module as an example
For access
This directory contains indexphp files in the current directory
to 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.
What is in the file indexphp?
Copy code
The code reads as follows:
"PHP?
Require_once /include/commonincphp;
$lastedittime = @filemtime (index_cachehtml) ;
$lastedittime = $PHP_TIME$lastedittime;
$autoupdatetime = intval ($MOD[autoupdate] ) ;
//$MOD[autoupdate] comes from the contents of the 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 determine whether the file is invalid, filedata/cache/wenba_settingphp has the following settings, inwhichthe value of the fieldAutoUpdate is the file failure time,unit is 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
The code reads 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 settings function
Copy code
The code reads as follows:
Function module_setting ($module $setting)
{
G l ob al $db$MODULE$LANG;
If ( ! Is_array ($setting) | | ! Array_key_exists
($modul e$MODULE) ) return FALSE;
If (isset ($setting[moduledomainPrivate, Const,
MAX_IDE_DR IVESwww.mnmm8.c omAs, Long=, Max, number, of, driv es,assuming, primary/secondary, master/slave, topology])){
$moduledomain = $setting[moduledomain] ;
$db>que ry ("UPDATE", "TAB LE_MOD ULE", "S ET,moduledomain=$modul edomai n, WHERE, module=$modul e") ;
Unset ($setting[moduledomain]) ;
}
$setting = addslashes (serialize (new_stripslashes
($setting) )) ;
Will / more than one set of values for a module. After arrayserialization is stored in a field in setting
$db>que ry ("UPDATE", "TABLE_MODULE", "S ET, s et t i n g=$s et t i n g,WHERE, modul e=$modu l e") ;
Cache_module ($module) ;
Cache_common () ;
Return TRUE;
}
C generates static cache files within a dynamic page
With the principle of B is similar to the cache file name isgenerated according to the calculated $PHP_SELF and
$PHP_QUERYSTRING value of MD generated file name relative toall PHP dynamic pages are the same thought classic comparisonshould be signed by
Take the question module as an example
The file call order is indexphp> jsphp >adphp> globalfuncphpFor access
This directory contains indexphp files in the current directoryto determine whether there is a file called index_cachehtml
directly if this file is included if it doesnot exist this fileare dynamically read after the data stored in theindex_cachehtml file for the next use.
When accessing the above URL, the page contains the followingline of JS code
<script language=, "JavaScript",
"/opensource/phpcms_sp_gbk/phpcms/data/jsphp", "id=",src=, ></script>
This JS code is actually a dynamic call to the content of thePHP page
The contents of the jsphp file:
Copy code
The code reads as follows:
"PHP?
Chdir (/ads/) ;
Require /adphp;
>?
Adphp content
Copy code
The code reads as follows:
"PHP?
D ef i ne (SHOWJS) ;
Require /include/commonincphp;
Require MOD_ROOT/include/globalfuncphp; </p> <p>$placeid =i ntval ($i d) ; </p> <p>$qu ery = "SELECT * FROM" TABLE_ADS "ASa LEFT"JOIN"TABLE_ADS_PLACE AS P ON(aplaceid=pplaceid) WHEREaplacei d=" $p laceid "AND afromdate<=UNIX_TIMESTAMP (AND)atodate>=UNIX_TIMESTAMP (AND) ppassed= AND apassed= ANDachecked= ORDER BY aaddtime";
$ads = $db>ge t_one ($query "CAHCE") ;
I f ( ($ads) ex it (documentwri te (")") ; </p>, <p>$db>query("UPDATE", "SET, views=views+, WHERE, adsid=", $ads[ads id] ) ;</p> <p>$content = ads_content ($ads) (TABLE_ADS) ;
$templateid = $ads[templateid]? $ads[templateid] : ads;Include template (ads $templateid) ;
Phpcache () ;
>?
Adphp which calls the phpcache function reference file
昔日数据怎么样?昔日数据是一个来自国内服务器销售商,成立于2020年底,主要销售国内海外云服务器,目前有国内湖北十堰云服务器和香港hkbn云服务器 采用KVM虚拟化技术构架,湖北十堰机房10M带宽月付19元起;香港HKBN,月付12元起; 此次夏日活动全部首月5折促销,有需要的可以关注一下。点击进入:昔日数据官方网站地址昔日数据优惠码:优惠码: XR2021 全场通用(活动持续半个月 2021/7...
今天父亲节我们有没有陪伴家人一起吃个饭,还是打个电话问候一下。前一段时间同学将网站账户给我说可以有空更新点信息确保他在没有时间的时候还能保持网站有一定的更新内容。不过,他这个网站之前采用的主题也不知道来源哪里,总之各种不合适,文件中很多都是他多年来手工修改的主题拼接的,并非完全适应WordPress已有的函数,有些函数还不兼容最新的PHP版本,于是每次出现问题都要去排查。于是和他商量后,就抽时间把...
Sharktech(鲨鱼服务器商)我们还是比较懂的,有提供独立服务器和高防服务器,而且性价比都还算是不错,而且我们看到有一些主机商的服务器也是走这个商家渠道分销的。这不看到鲨鱼服务器商家洛杉矶独立服务器纷纷促销,不限制流量的独立服务器起步99美元,这个还未曾有过。第一、鲨鱼机房服务器方案洛杉矶机房,默认1Gbps带宽,不限流量,自带5个IPv4,免费60Gbps / 48Mpps DDoS防御。C...