好!欢迎访问迷津渡口 现在时间是: 天气 °C ~ °C

迷津渡口

越感到迷惑 越接近真理

emlog MVC解构7--工具类们之Cache

emlog拥有各种各样的工具类,保存在include/lib/里。

下面首先来分析非常重要的Cache文本缓存类。

属性表:

属性注释
private $db一个数据库类实例,一个MySql或者MySqlii类实例,两种类属性和方法一致
private static $instance = null静态属性,一个Cache类的实例
private $options_cache站点配置缓存,emlog_options表的数组形式
private $user_cache用户信息缓存,emlog_user表的数组形式
private $sta_cache

站点统计缓存,包含全站和每个用户的日志、评论、微语信息:

array(

'lognum' => emlog_blog表已提交的日志总数量,

'draftnum' => emlog_blog表草稿的数量,

        'checknum' => emlog_blog表未审核的日志数量,

'comnum' => emlog_comment表已审核发表的评论数量,

        'hidecomnum' => emlog_comment表未审核的评论数量,

'comnum_all' => emlog_comment表已提交的评论总数量,

'twnum' => emlog_twitter表已发表的微语总数量,

        // 每个用户的日志、评论和微语信息,下面仅列出一个模板

        '$userid' => array (

'lognum' => 此用户已提交的日志总数量,

'draftnum' => 此用户草稿的数量,

'commentnum' => 此用户被审核通过评论数量,

'hidecommentnum' => 此用户未被审核通过的评论数量,

'twnum' => 此用户发表的微语数量

        ),

);


private $comment_cache

最新评论缓存数组,一般是10条评论,每条评论包含:

array(

'cid' => 评论唯一ID,

'gid' => 评论所属日志ID,

'name' => 评论提交者名称,

'date' => 评论提交时间戳,

'page' => 评论在第几页,

'mail' => 评论提交者的邮箱,

'content' => 评论内容,

);


private $tags_cache

侧边栏标签缓存数组,每个标签数组包含:

array(

'tagurl' => 标签的地址,仅包含标签部分,如http://www.qingzz.cn/tag/emlog是emlog的访问地址则这里的值为emlog,

'tagname' => 标签的名字,

'fontsize' => 标签的字体大小,

'usenum' => 标签被使用的次数

);


private $sort_cache侧边栏分类缓存数组,emlog_sort表的数组形式
private $link_cache友情链接缓存数组,emlog_link表的数组形式
private $navi_cache导航缓存数组,emlog_navi表的数组形式
private $newlog_cache最新文章缓存数组,一般是10篇文章
private $newtw_cache最新微语缓存数组,一般是10条微语
private $record_cache
文章归档缓存数组,根据月和日为分组方式归档文章
private $logtags_cache文章标签缓存数组,每篇文章标签构成二级数组
private $logsort_cache文章分类缓存数组,每篇文章分类构成二级数组
private $logalias_cache文章别名缓存数组

方法表:

方法注释
private function __construct()构造方法,配置$this->db实例化数据库连接
public static function getInstance()静态方法,配置$this->instance为数据库连接实例并返回
function updateCache($cacheMethodName=null)

用以调用内部类似mc_xxx()更新缓存,参数$cacheMethodName默认为null,此时函数将调用所有Cache类的mc_xxx方法,更新所有缓存;更新单个缓存时,$cacheMethodName配置为需要更新缓存的属性字符串,如'options',则函数将单独调用mc_options();更新多个缓存时,$cacheMethodName配置为多个需要更新缓存的属性字符串组成的数组,如array('options','user'),则函数将按顺序调用mc_options()和mc_user()。

注意:

更新缓存的方法以mc_开头,后面跟更新的属性名称

private function mc_options()站点配置缓存更新,将emlog_options表简单处理并serialize后的字符串缓存,调用writeCache写入options.php文件,失败则仍以数组形式保留在$options_cache属性里
private function mc_user()用户信息缓存更新,emlog_user表简单处理并serialize后的字符串缓存,调用writeCache写入user.php文件,失败则仍以数组形式保留在$user_cache属性里
private function mc_sta()

站点统计缓存更新,通过统计查询获取的站点统计信息处理并serialize后的字符串缓存,调用writeCache写入sta.php文件,失败则仍以数组形式保留在$sta_cache属性里


private function mc_comment()最新评论缓存更新,根据Options配置的个数获取侧边栏输出的最新评论的信息处理并serialize后的字符串缓存,调用writeCache写入comment.php文件,失败则仍以数组形式保留在$comment_cache属性里
private function mc_tags()侧边栏标签缓存更新,处理后serialize后的字符串缓存,调用writeCache写入tags.php文件,失败则仍以数组形式保留在$tags_cache属性里
private function mc_sort()侧边栏分类缓存更新,emlog_sort表简单处理并serialize后的字符串缓存,调用writeCache写入sort.php文件,失败则仍以数组形式保留在$sort_cache属性里
private function mc_link()友情链接缓存更新,emlog_link表简单处理并serialize后的字符串缓存,调用writeCache写入link.php文件,失败则仍以数组形式保留在$link_cache属性里
private function mc_navi()导航缓存更新,emlog_navi表简单处理并serialize后的字符串缓存,调用writeCache写入navi.php文件,失败则仍以数组形式保留在$navi_cache属性里
private function mc_newlog()最新文章缓存更新,根据Options配置的个数获取侧边栏输出的最新文章的信息处理并serialize后的字符串缓存,调用writeCache写入newlog.php文件,失败则仍以数组形式保留在$newlog_cache属性里
private function mc_newtw()最新微语缓存更新,根据Options配置的个数获取侧边栏输出的最新文章的信息处理并serialize后的字符串缓存,调用writeCache写入newtw.php文件,失败则仍以数组形式保留在$newtw_cache属性里
private function mc_record()文章归档缓存更新,根据月和日为分组方式归档文章,处理信息并serialize后的字符串缓存,调用writeCache写入record.php文件,失败则仍以数组形式保留在$record_cache属性里
private function mc_logtags()

文章标签缓存更新,每篇文章标签构成二级数组,处理信息并serialize后的字符串缓存,调用writeCache写入logtags.php文件,失败则仍以数组形式保留在$logtags_cache属性里

private function mc_logsort()文章分类缓存更新,每篇文章分类构成二级数组,处理信息并serialize后的字符串缓存,调用writeCache写入logsort.php文件,失败则仍以数组形式保留在$logsort_cache属性里
private function mc_logalias()文章别名缓存更新,处理信息并serialize后的字符串缓存,调用writeCache写入logalias.php文件,失败则仍以数组形式保留在$logalias_cache属性里
function cacheWrite($cacheData,$cacheName)

写入缓存,$cacheData是更新缓存的函数将数组serialize之后的结果,$cacheName是缓存属性的名称。

一般情况下,数据将保存在EMLOG_ROOT.'/content/cache/'.$cacheName.'.php'文件里面,php文件保存是因为添加必要的代码后可以保证用户无法通过访问地址获取缓存数据,数据为"<?php exit;//".$cacheData,访问此文件时将直接退出,不会访问后面的数据。另外写入后实例属性保存的数据将被清空,需要用readCache()重新将数据从文件获取到属性。

特殊情况下,就是文件无法打开写入的情况下,缓存将仍以字符串的形式保留在缓存实例的属性里。

function readCache($cacheName)读取缓存文件,$cacheName是缓存属性的名称,如果实例相应的属性里面已经有数据,则直接返回属性保存的数据。如果缓存不存在则自动生成缓存后再把数据写入属性里,经过去除前缀和unserialize的处理后返回属性保存的数据。


点赞0
 标签: emlog mvc cache
   支持一下
挤眼 亲亲 咆哮 开心 想想 可怜 糗大了 委屈 哈哈 小声点 右哼哼 左哼哼 疑问 坏笑 赚钱啦 悲伤 耍酷 勾引 厉害 握手 耶 嘻嘻 害羞 鼓掌 馋嘴 抓狂 抱抱 围观 威武 给力
 点赞
 签到
 表情
 图片
 代码
提交评论

清空信息
关闭评论
exechars
 exechars 约 4 小时前回复
#94
<a href="http://www.advube.com/air-jordan-7-retro-bianca-grigio-blu-viola-yeezy-kurpesc">air jordan 7 retro bianca grigio blu viola yeezy</a> <a href="http://www.awolfdesigns.com/air-jordan-retro-4-mujeres-cielo-azul-azul-obuva">air jordan retro 4 mujeres cielo azul azul</a> <a href="http://www.bigponid.com/nike-mercurial-vapor-hvit-and-r%C3%B8d-schuhef">nike mercurial vapor hvit and r酶d</a> <a href="http://www.chemonomic.com/mennns-asics-asics-gel-kinsei-2-hvit-gr%C3%B8nn-chaussuresg">mennns asics asics gel kinsei 2 hvit gr酶nn</a> <a href="http://www.danniewells.com/nike-huarache-utility-for-venta-nj-obuvc">nike huarache utility for venta nj</a> <a href="http://www.dssdgjhu.com/nike-kd-trey-5-rot-mint-volt-schwarz-guy-kurpesb">nike kd trey 5 rot mint volt schwarz guy</a>
exechars http://www.exechars.com/
saleuggboot
 saleuggboot 约 16 小时前回复
#93
<a href="http://www.findatrans.com/nike-air-presto-ultra-flyknit-herren-schwarz-schuhej">nike air presto ultra flyknit herren schwarz</a> <a href="http://www.isabellerigal.com/nike-roshe-run-hot-lyser%C3%B8d-skoh">nike roshe run hot lyser酶d</a> <a href="http://www.esnafkocaeli.com/hommes-nike-blazer-violet-vert-chaussuresh">hommes nike blazer violet vert</a> <a href="http://www.dkdjabar.com/detroit-tigers-nike-mlb-ligature-swoosh-flex-cap-hatl">detroit tigers nike mlb ligature swoosh flex cap</a> <a href="http://www.jamiecirillo.com/nike-shox-deliver-gris-argent-chaussuresh">nike shox deliver gris argent</a> <a href="http://www.xpostshopx.com/air-jordan-super-fly-naranja-blanco-zapatosp">air jordan super fly naranja blanco</a>
saleuggboot http://www.saleuggboot.com/
moldedeps
 moldedeps 2019-02-15 05:58回复
#92
<a href="http://www.apconcierge.com/nike-magista-cleats-on-vente-yuma-az-obuvb">nike magista cleats on vente yuma az</a> <a href="http://www.freonsystem.com/hombres-salomon-fell-raiser-azul-cielo-azul-butya">hombres salomon fell raiser azul cielo azul</a> <a href="http://www.jupitertaxx.com/dion-sims-mens-limited-camo-jersey-nike-nfl-chicago-bears-rush-realtree-88-nflu">dion sims mens limited camo jersey nike nfl chicago bears rush realtree 88</a> <a href="http://www.khyenchen.com/nike-air-max-90-l%C3%A6der-infrar%C3%B8d-kurpesb">nike air max 90 l忙der infrar酶d</a> <a href="http://www.latinphonics.com/mujeres-air-max-90-em-rosado-gris-schuhec">mujeres air max 90 em rosado gris</a> <a href="http://www.liaqui.com/nike-kvinners-free-3.0-v4-bl%C3%A5-gr%C3%A5-parts-schuheg">nike kvinners free 3.0 v4 bl氓 gr氓 parts</a>
moldedeps http://www.moldedeps.com/
ipartybooths
 ipartybooths 2019-02-14 19:08回复
#91
<a href="http://www.rellthewolf.com/orange-silver-mens-air-jordan-b-mo-shoes-sneakere">orange silver mens air jordan b mo shoes</a> <a href="http://www.fincasagaro.com/kvinders-nike-roshe-yeezy-boost-himmelbl%C3%A5-obuvd">kvinders nike roshe yeezy boost himmelbl氓</a> <a href="http://www.mushigiftpack.com/nike-super-bowl-lii-youth-elandon-roberts-limited-red-alternate-jersey-new-england-patriots-nfl-52-vapor-untouchable-nflw">nike super bowl lii youth elandon roberts limited red alternate jersey new england patriots nfl 52 vapor untouchable</a> <a href="http://www.glplawyers.com/2014-15-chelsea-fc-26-terry-home-soccer-shirt-kit-nflv">2014 15 chelsea fc 26 terry home soccer shirt kit</a> <a href="http://www.canditatenext.com/nike-air-force-1-high-foamposite-black-skog">nike air force 1 high foamposite black</a> <a href="http://www.ganuocdua.com/billig-nike-kobe-9-dam%C3%A4nner-gold-skob">billig nike kobe 9 dam盲nner gold</a>
[url=http://www.ipartybooths.com/]ipartybooths[/url]
visheshcap
 visheshcap 2019-02-14 07:50回复
#90
<a href="http://www.truthtapes.com/nike-kyrie-3-oro-rosado-zapatosk">nike kyrie 3 oro rosado</a> <a href="http://www.veskopetrov.com/kvinders-nike-flyknit-lunar-3-sort-lilla-skoi">kvinders nike flyknit lunar 3 sort lilla</a> <a href="http://www.kaosmotogp.com/nike-air-max-2017-hvit-gr%C3%B8nn-obuvl">nike air max 2017 hvit gr酶nn</a> <a href="http://www.doularhythms.com/womens-nike-roshe-yeezy-boost-yellow-blue-shoesh">womens nike roshe yeezy boost yellow blue</a> <a href="http://www.animalpainvet.com/nike-air-max-stefan-janoski-wolf-grigio-scarpei">nike air max stefan janoski wolf grigio</a> <a href="http://www.texarillo.com/nike-zoom-vomero-dam%C3%A4nner-silber-wei%C3%9F-schuhej">nike zoom vomero dam盲nner silber wei脽</a>
visheshcap http://www.visheshcap.com/
iranqnap
 iranqnap 2019-02-12 17:57回复
#89
<a href="http://www.genevacollins.com/flyknit-trainer-rosa-bl%C3%A5-quilt-kurpesb">flyknit trainer rosa bl氓 quilt</a> <a href="http://www.kuaconsulting.com/nike-womens-josh-gordon-limited-navy-blue-jersey-new-england-patriots-nfl-10-therma-long-sleeve-nflr">nike womens josh gordon limited navy blue jersey new england patriots nfl 10 therma long sleeve</a> <a href="http://www.ventaasesoria.com/nike-free-tr-dam%C3%A4nner-gelb-wei%C3%9F-butyg">nike free tr dam盲nner gelb wei脽</a> <a href="http://www.yerutribe.com/orioles-blank-grey-fashion-stars-stripes-flexbase-authentic-stitched-mlb-jersey-nflz">orioles blank grey fashion stars stripes flexbase authentic stitched mlb jersey</a> <a href="http://www.filleselfie.com/ash-solomon-thomas-womens-jersey-94-nike-nfl-one-color-san-francisco-49ers-pullover-hoodie-nflx">ash solomon thomas womens jersey 94 nike nfl one color san francisco 49ers pullover hoodie</a> <a href="http://www.fourhourgun.com/kyrie-1-university-r%C3%B8d-wing-chaussuresa">kyrie 1 university r酶d wing</a>
iranqnap http://www.iranqnap.com/
tobepartridge
 tobepartridge 2019-02-12 07:31回复
#88
<a href="http://www.wuxiangtaichi.com/washington-nationals-new-era-mlb-2-tone-link-9fifty-snapback-cap-hath">washington nationals new era mlb 2 tone link 9fifty snapback cap</a> <a href="http://www.culdesacmag.com/air-jordan-melo-gris-bleu-ciel-chaussuresh">air jordan melo gris bleu ciel</a> <a href="http://www.livinggreedy.com/nike-flyknit-lunar-3-rosa-argento-scarpel">nike flyknit lunar 3 rosa argento</a> <a href="http://www.clickstroy.com/adidas-harden-blue-gold-shoesj">adidas harden blue gold</a> <a href="http://www.zotorrent.com/air-jordan-retro-7-r%C3%B8d-lilla-skoi">air jordan retro 7 r酶d lilla</a> <a href="http://www.viptarimas.com/nike-kd-8-triple-nero-scarpeq">nike kd 8 triple nero</a>
tobepartridge http://www.tobepartridge.com/
wcshosting
 wcshosting 2019-02-10 05:38回复
#87
<a href="http://www.thebiarritz.com/air-jordan-retro-4-womens-red-yellow-shoesl">air jordan retro 4 womens red yellow</a> <a href="http://www.voydnet.com/steven-adams-okc-jersey-nfli">steven adams okc jersey</a> <a href="http://www.foneandlone.com/kvinners-nike-zoom-structure-18-royal-bl%C3%A5-obuvk">kvinners nike zoom structure 18 royal bl氓</a> <a href="http://www.roomwhiz.com/coach-keri-apricot-sunglasses-coachh">coach keri apricot sunglasses</a> <a href="http://www.riffsurfers.com/adidas-zx-flux-femminile-verde-scarpei">adidas zx flux femminile verde</a> <a href="http://www.davidmgaines.com/nike-free-run-2-femminile-verde-cielo-blu-scarpeh">nike free run 2 femminile verde cielo blu</a>
wcshosting http://www.wcshosting.com/
maxfullforce
 maxfullforce 2019-02-09 08:11回复
#86
<a href="http://www.carlosbartolo.com/p%C3%BArpura-and-blanco-jordan-6-gs-kurpesb">p煤rpura and blanco jordan 6 gs</a> <a href="http://www.chiragsblog.com/mens-nike-baltimore-ravens-5-joe-flacco-elite-black-alternate-nfl-jersey-nflr">mens nike baltimore ravens 5 joe flacco elite black alternate nfl jersey</a> <a href="http://www.eventyrshop.com/nike-zoom-pegasus-31-junior-l%C3%B8b-sko-butyg">nike zoom pegasus 31 junior l酶b sko</a> <a href="http://www.firmayoga.com/blue-devils-1-jabari-parker-blue-basketball-elite-stitched-ncaa-jersey-nflx">blue devils 1 jabari parker blue basketball elite stitched ncaa jersey</a> <a href="http://www.keiservices.com/limited-nike-black-mens-james-conner-jersey-nfl-30-pittsburgh-steelers-therma-long-sleeve-nflw">limited nike black mens james conner jersey nfl 30 pittsburgh steelers therma long sleeve</a> <a href="http://www.kmkonka.com/nike-air-max-87-sb-dark-gris-negro-blanco-chaussuresa">nike air max 87 sb dark gris negro blanco</a>
maxfullforce http://www.maxfullforce.com/
cosonventa
 cosonventa 2019-02-09 03:43回复
#85
<a href="http://www.juraamei.com/nike-dunk-sky-hi-bia%C5%82e-skos">nike dunk sky hi bia艂e</a> <a href="http://www.beoshoes.com/fendi-belt-tag-beltr">fendi belt tag</a> <a href="http://www.samuelzide.com/mackage-jacket-for-cheap-price-mackagee">mackage jacket for cheap price</a> <a href="http://www.zealouslyzika.com/nike-air-max-90-essential-grey-white-skow">nike air max 90 essential grey white</a> <a href="http://www.tjharkins.com/nike-cincinnati-bengals-28-bernard-scott-elite-orange-alternate-jersey-nflf">nike cincinnati bengals 28 bernard scott elite orange alternate jersey</a> <a href="http://www.bringussocial.com/oakland-raiders-new-jersey-nflr">oakland raiders new jersey</a>
cosonventa http://www.cosonventa.com/
顶部留言底部
 00:00/00:00
我想和你虚度时光 - 花房姑娘(9)
  1. 我想和你虚度时光
  2. 花房姑娘
  3. 恋恋风尘
  4. 我喜爱一切不彻底的事物
  5. 我的心里是满的
  6. Long Way
  7. 给少年的歌
  8. 晴日共剪窗
  9. 天上的月你的脸