phpFastCache - PHP 缓存库
MIT
跨平台
PHP
软件简介
phpFastCache 是一个开源的 PHP 缓存库,只提供一个简单的 PHP 文件,可方便集成到已有项目,支持多种缓存方法,包括:apc,
memcache, memcached, wincache, files, pdo and mpdo。可通过简单的 API 来定义缓存的有效时间。
示例代码:
<?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
}
?>