国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

? CMS ???? PHPCMS phpcms v9 ?? ??? ??? ??????

phpcms v9 ?? ??? ??? ??????

Jan 14, 2020 am 09:53 AM
phpcms

phpcms v9 ?? ??? ??? ??????

phpcms v9緩存文件是怎樣生成的?

這篇文章介紹phpcms的緩存結(jié)構(gòu)

我并沒有做深入的學(xué)習(xí),但是phpcms的想法上卻是有他的過人之處,太令人折服了,這里分享phpcms緩存的一中實現(xiàn)方案

/include/cache.func.php

這里最先主要是定義了一些phpcms的緩存函數(shù),phpcms的緩存分為,表緩存,模型緩存,模型字段緩存,還有模塊緩存,首先這些都是基于表的緩存的。

最開始有一個函數(shù)

function cache_all()
{
@set_time_limit(600);
cache_common();
cache_module();
cache_model();
cache_category();
cache_area();
cache_type();
cache_member_group();
    cache_role();
cache_author();
cache_keyword();
cache_copyfrom();
cache_pos();
    cache_status();
cache_workflow();
tags_update();
return TRUE;
}

這個函數(shù)就調(diào)用一大堆的緩存函數(shù)來生成緩存的。

首先第一個函數(shù) cache_common

大家可以看下面的注釋,是將 前綴名_model,前綴名_category ,前綴名_ module,前綴名,前綴名_type,前綴名_area,等等寫入到$CACHE數(shù)組的對應(yīng)下表之中 (比如model 表的數(shù)據(jù)$CACHE["model"]=$arr,$arr為phpcms_model表的數(shù)據(jù))

function cache_common()
{
global $db;
$data = array();
$result = $db->query("SELECT `module`,`name`,`path`,`url`,`iscore`,`version` FROM `".DB_PRE."module` WHERE `disabled`=0");
while($r = $db->fetch_array($result))
{
   if(!$r['path']) $r['path'] = $r['module'] == 'phpcms' ? '' : $r['module'].'/';
   if(!$r['url']) $r['url'] = $r['module'] == 'phpcms' ? '' : $r['module'].'/';
   $data[$r['module']] = $r;
}
$db->free_result($result);
$CACHE['MODULE'] = $data;
//以上是將對應(yīng)的模塊寫入$CACHE;
$data = array();
$result = $db->query("SELECT * FROM `".DB_PRE."model` WHERE `disabled`=0");
while($r = $db->fetch_array($result))
{
   $data[$r['modelid']] = $r;
}
$db->free_result($result);
$CACHE['MODEL'] = $data;
$data = array();
//以上是對應(yīng)的 model表里的內(nèi)容寫入數(shù)組$CACHE;
$result = $db->query("SELECT `catid`,`module`,`type`,`modelid`,`catname`,`style`,`image`,`catdir`,`url`,`parentid`,`arrparentid`,`parentdir`,`child`,`arrchildid`,`items`,`citems`,`pitems`,`ismenu`,`letter` FROM `".DB_PRE."category` WHERE 1 ORDER BY `listorder`,`catid`");
while($r = $db->fetch_array($result))
{
   $r['url'] = url($r['url']);
   $data[$r['catid']] = $r;
}
$db->free_result($result);
$CACHE['CATEGORY'] = $data;
//以上是將所有的欄目寫入$CACHE數(shù)組
$data = array();
$result = $db->query("SELECT `typeid`,`modelid`,`module`,`name`,`style`,`typedir`,`url` FROM `".DB_PRE."type` WHERE 1 ORDER BY `listorder`,`typeid`");
while($r = $db->fetch_array($result))
{
   $data[$r['typeid']] = $r;
}
$db->free_result($result);
$CACHE['TYPE'] = $data;
//以上是將所有的 類別表里的數(shù)據(jù)寫入$CACHE
$data = array();
$result = $db->query("SELECT `areaid`,`name`,`style`,`parentid`,`arrparentid`,`child`,`arrchildid` FROM `".DB_PRE."area` WHERE 1 ORDER BY `listorder`,`areaid`");
while($r = $db->fetch_array($result))
{
   $data[$r['areaid']] = $r;
}
$db->free_result($result);
$CACHE['AREA'] = $data;
//所有的地區(qū)表寫入$CACHE;
$data = array();
$result = $db->query("SELECT `urlruleid`,`urlrule` FROM `".DB_PRE."urlrule` WHERE 1 ORDER BY `urlruleid`");
while($r = $db->fetch_array($result))
{
   $data[$r['urlruleid']] = $r['urlrule'];
}
$db->free_result($result);
$CACHE['URLRULE'] = $data;
//將所有的url規(guī)則寫入緩存
$data = array();
    $r = $db->get_one("SELECT `setting` FROM `".DB_PRE."module` WHERE `module`='phpcms'");
$setting = $r['setting'];
eval("\$PHPCMS = $setting;");
if($PHPCMS['siteurl'] =='') $PHPCMS['siteurl'] = SITE_URL;
$CACHE['PHPCMS'] = $PHPCMS;
//最后調(diào)用cache_write方法將所有的數(shù)組寫入common.php 位置/date/cache/common.php根據(jù)系統(tǒng)變量慧有所改動
cache_write('common.php', $CACHE);
    
return $CACHE;
}

phpcms表緩存的實現(xiàn)方式主要是:利用一個叫cache_table函數(shù)$table是要緩存的表名,$fileds 是查詢的字段名字,默認為 ' * ',$where sql語句中的where 子句,$order 排序, $isline是否開啟字段緩存默認為不開啟,如果開啟表字段緩存和表緩存將同時進行

function cache_table($table, $fields = '*', $valfield = '', $where = '', $order = '', $iscacheline = 0, $number = 0)
{
global $db;
$keyfield = $db->get_primary($table);
$data = array();
if($where) $where = " WHERE $where";
if(!$order) $order = $keyfield;
$limit = $number ? "LIMIT 0,$number" : '';
$result = $db->query("SELECT $fields FROM `$table` $where ORDER BY $order $limit");
$table = preg_replace("/^".DB_PRE."(.*)$/", "", $table);
while($r = $db->fetch_array($result))
{
   if(isset($r['setting']) && !empty($r['setting']))
   {
    $setting = $r['setting'];
    eval("\$setting = $setting;");
    unset($r['setting']);
    if(is_array($setting)) $r = array_merge($r, $setting);
        }
   $key = $r[$keyfield];
   $value = $valfield ? $r[$valfield] : $r;
   $data[$key] = $value;
   if($iscacheline) cache_write($table.'_'.$key.'.php', $value); //表字段緩存
}
$db->free_result($result);
cache_write($table.'.php', $data) ;// 表緩存
}

將數(shù)據(jù)數(shù)組寫入對應(yīng)的緩存文件,以上這個函數(shù)就是判斷下常量CACHE_PATH是否存在默認是data/cache的路徑然后用file_put_contents 將緩存的數(shù)據(jù)寫入到對應(yīng)的cachefile中

function cache_write($file, $array, $path = '')
{
if(!is_array($array)) return false;
$array = "<?php\nreturn ".var_export($array, true).";\n?>";
$cachefile = ($path ? $path : CACHE_PATH).$file;
$strlen = file_put_contents($cachefile, $array);
@chmod($cachefile, 0777);
return $strlen;
}

至于其他的可以參照以上的方法進行添加,大家可以查查看對應(yīng)的cache.func.php

//緩存模型表
function cache_model()
{
cache_table(DB_PRE.&#39;model&#39;, &#39;*&#39;, &#39;&#39;, &#39;&#39;, &#39;modelid&#39;, 1);
}
//緩存分類表生成文件路徑是../data/cachecategory_catid.php
function cache_category()
{
cache_table(DB_PRE.&#39;category&#39;, &#39;*&#39;, &#39;&#39;, &#39;&#39;, &#39;listorder,catid&#39;, 1);
}

緩存類別表生成路徑

../data/cache/type_typeid.php
function cache_type()
{
cache_table(DB_PRE.&#39;type&#39;, &#39;*&#39;, &#39;&#39;, &#39;&#39;, &#39;listorder,typeid&#39;, 1);
}
//緩存地區(qū)列表

生成路徑:../data/cache/area_areaid.php

function cache_area()
{
cache_table(DB_PRE.&#39;area&#39;, &#39;*&#39;, &#39;&#39;, &#39;&#39;, &#39;listorder,areaid&#39;, 1);
}
//緩存用戶組表
//生成路徑:../data/cache member_grounp_group_id.php
function cache_member_group()
{
cache_table(DB_PRE.&#39;member_group&#39;, &#39;*&#39;, &#39;&#39;, &#39;&#39;, &#39;groupid&#39;, 1);
cache_table(DB_PRE.&#39;member_group&#39;, &#39;*&#39;, &#39;name&#39;, &#39;&#39;, &#39;groupid&#39;, 0);
}
//緩存角色表
//生成路徑:../data/cache/role_roleid.php
function cache_role()
{
cache_table(DB_PRE.&#39;role&#39;, &#39;*&#39;, &#39;name&#39;, &#39;&#39;, &#39;listorder,roleid&#39;);
}
//緩存作者表
//生成路徑:../data/cache/author_authorid.php
function cache_author()
{
cache_table(DB_PRE.&#39;author&#39;, &#39;*&#39;, &#39;name&#39;, &#39;&#39;, &#39;listorder,authorid&#39;, 0, 100);
}
function cache_keyword()
{
cache_table(DB_PRE.&#39;keyword&#39;, &#39;*&#39;, &#39;tag&#39;, &#39;&#39;, &#39;listorder,usetimes&#39;, 0, 100);
}
function cache_copyfrom()
{
cache_table(DB_PRE.&#39;copyfrom&#39;, &#39;*&#39;, &#39;&#39;, &#39;&#39;, &#39;listorder,usetimes&#39;, 0, 100);
}
function cache_pos()
{
cache_table(DB_PRE.&#39;position&#39;, &#39;*&#39;, &#39;name&#39;, &#39;&#39;, &#39;listorder,posid&#39;, 0);
}

PHP中文網(wǎng),大量的免費PHPCMS教程,歡迎在線學(xué)習(xí)!

? ??? phpcms v9 ?? ??? ??? ??????? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? ????? ??
? ?? ??? ????? ???? ??? ??????, ???? ?????? ????. ? ???? ?? ???? ?? ??? ?? ????. ???? ??? ???? ???? ??? ?? admin@php.cn?? ?????.

? AI ??

Undresser.AI Undress

Undresser.AI Undress

???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover

AI Clothes Remover

???? ?? ???? ??? AI ?????.

Video Face Swap

Video Face Swap

??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

???

??? ??

???++7.3.1

???++7.3.1

???? ?? ?? ?? ???

SublimeText3 ??? ??

SublimeText3 ??? ??

??? ??, ???? ?? ????.

???? 13.0.1 ???

???? 13.0.1 ???

??? PHP ?? ?? ??

???? CS6

???? CS6

??? ? ?? ??

SublimeText3 Mac ??

SublimeText3 Mac ??

? ??? ?? ?? ?????(SublimeText3)

???

??? ??

??? ????
1601
29
PHP ????
1502
276
???
phpcms?? ???? ???? ???? ?? phpcms?? ???? ???? ???? ?? Jul 27, 2023 pm 05:23 PM

phpcms?? ???? ???? ???? ??: 1. ?? ??? ???? ?? ??? ?????. 2. ??? ??? ?????. 3. ???? ??? ???? ??? ??? ?????.

phpcms? ?? ????????? phpcms? ?? ????????? Apr 20, 2024 pm 10:51 PM

PHP CMS? ? ??? ??? ??? ?? PHP ?? ?? ?? ??? ?? ?????, ?? ???, ??? ??, ???, ?? ?? ? ?? ?? ??? ?????. ??? ????, ???? ??? ?????, ??? ????, ?? ??? ??? ? ???, ?? ????, ???, ?? ????, ????? ????, ???? ?? ? ??? ?????? ?? ???? ????.

phpcms? ?? ????? phpcms? ?? ????? Mar 01, 2023 am 10:24 AM

phpcms? ?? ??? ????. phpcms? ?? ?? cms ?????? ?? ??? ?? ??? ??? ??? ? ?? ??? ????. ????? ????, ???? ???? ?? ??? ???? ???.

WeChat ??? ?? ???: PHPCMS ?? ?? WeChat ??? ?? ???: PHPCMS ?? ?? Mar 29, 2024 am 09:18 AM

??: WeChat ??? ?? ???: PHPCMS? ?? ??? ??? ??? ?? ???? ????? ?? ?? ? ??? ?????. ???? ?? ?? ?? ?? ??? ? ??? WeChat? ??? ??? ?? ? ?? ??????? ???? ????. ? ????? WeChat ??? ??? PHPCMS ????? ???? ??? ???? ???? ?? ??? ?????. 1??: WeChat Open Platform ?? ?? ?? WeChat Open Platform? ??? ??? ???? ?? ?? ??? ???? ???. ??? [?? ?? ???]

PHPCMS ??? ?? ?? ?? ?? ?? PHPCMS ??? ?? ?? ?? ?? ?? Mar 14, 2024 pm 12:06 PM

PHPCMS ??? ?? ?? ?? ?? ?? ? ??? ???? ??? ?? ??? ?? ???? ?? ???? ???? ???????. ??? ??? ?? ??? ?????. ??? ??? ???? ??? ?? ??? ?? ??? ???? ?? ??? ???? ?? ??? ??? ?? ?? ?????. ? ????? PHPCMS? ??? ?? ?? ?? ??? ???? ???? ??? ? ?? ???? ?? ??? ?????. 1. ???? ??? ??? ???? ?? ???? ??? ??? ??? ??? ???? ???.

phpcms? ?? ????? phpcms? ?? ????? Apr 20, 2024 pm 10:39 PM

PHPCMS? ?? ??, ???, ???, ??? ??? ? ???? ??? ?? ?? ?? ?? ??? ?? ???(CMS)???. ?? ????, ????? ????, ???, ???? ?? ? ??? ??? ????? ??? ? ??? ? ????. ?? ?? ???? PHP 5.6 ??, MySQL, MariaDB ?? PostgreSQL ??????, Apache ?? Nginx ? ??? ?????.

phpcms?? ?? ??? ???? phpcms?? ?? ??? ???? Jun 14, 2023 pm 01:13 PM

phpcms?? ? ?? ? ??? ??? ????. 1. ??? ?? URL ??? ???? phpCMS4 ???? ?? ??? ???? ???? ??? ??? ???? ??? ? ?? ?? ????? ????? ????. . ???, ?? ??? ??, ??? ??? ???? phpCMS2008R1 ???? ???? ???? ?? ??? ??? ?????.

phpcms? ?? ??????? ?????? phpcms? ?? ??????? ?????? Feb 21, 2023 pm 06:57 PM

phpcms? mysql ??????? ?????. phpcms? PHP+MYSQL? ?? ???? ???? ??? PHP ?? ?? ???? ?? ??????. PHPCMS V9? OOP ??? ???? ?? ?? ?????? ?????. ???? PHP ??? PHP5 ??, ???? MYSQL ??? MySql 4.1 ?????.

See all articles