dongre6227 2013-12-29 05:57
浏览 17
已采纳

对称缓存机制

I have designed a tiny PHP framework for one of my customers 2 years ago, To make this system faster I implement a simple PHP page caching mechanism.

This simple mechanism require an interval value and compare it with the last time of page modified time, like the following example:

$interval = 5 * 3600;
$filename = ....

if ( file_exists($filename) && (time() - $interval) < filemtime($filename) ) {
    readfile($filename);
    exit();
}

// Rest of the code

Now, according to my customer request I have to make few changes in this Framework and one of the important things in this list is my Caching-System.

My customer says that current mechanism doesn't work symmetrically - e.g assuming that website home-page and category-page follow the above mechanism, Now if my customer add a new item in homepage, the item will first shown in category page and then shown in homepage if both page get expired in two different times.

Is there any way to make this mechanism symmetric without using any external library?

Thanks in advance...

  • 写回答

1条回答 默认 最新

  • doulianxi0587 2013-12-29 05:59
    关注

    What about clearing all cached items whenever a content update happens ? Easy, short and safe.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部