我發現phpfastcahce緩存MySQL結果的類。在支持WINCACHE,內存緩存,文件,X-Cache功能,APC緩存,說細節:php緩存動態索引頁面
在示例代碼PHP Caching Class For Database : Your website have 10,000 visitors who are online, and your dynamic page have to send 10,000 same queries to database on every page load. With phpFastCache, your page only send 1 query to DB, and use the cache to serve 9,999 other visitors.
:
<?php
// In your config file
include("php_fast_cache.php");
// This is Optional Config only. You can skip these lines.
// phpFastCache support "apc", "memcache", "memcached", "wincache" ,"files", "pdo", "mpdo" and "xcache"
// You don't need to change your code when you change your caching system. Or simple keep it auto
phpFastCache::$storage = "auto";
// End Optionals
// In your Class, Functions, PHP Pages
// try to get from Cache first.
$products = phpFastCache::get("products_page");
if($products == null) {
$products = YOUR DB QUERIES || GET_PRODUCTS_FUNCTION;
// set products in to cache in 600 seconds = 10 minutes
phpFastCache::set("products_page",$products,600);
}
foreach($products as $product) {
// Output Your Contents HERE
}
?>
現在,在我的我的網站的索引我有什麼塊顯示最新消息,最好的消息,世界新聞.....爲緩存我的索引,我必須緩存MySQL
每個塊的結果(last news, best news, world news .....)
使用phpfastcache和管理頁面刪除所有緩存如果我編輯現有消息或添加新消息?這是一個真正的方法?
什麼是最好的方式對於緩存MySQL
結果我的索引頁使用phpfastcache(任何方法)?!
不是特定於phpfastcache(我並不熟悉),但通常在使用任何緩存時,您需要有關於如何處理緩存未命中的策略(即,查詢數據庫並將結果填充到緩存中),並處理從緩存中取消/清除項目(在更改爲基礎數據時清除緩存項,對緩存項應用TTL)等。 – 2014-09-23 21:48:38
確實解答了您的問題嗎? – 2015-01-19 08:07:25