您当前的位置:首页 > 计算机 > 编程开发 > PHP

FastCache 高性能 PHP 对象缓存系统

时间:12-14来源:作者:点击数:
城东书院 www.cdsy.xyz

PHP FastCache 是一种高性能,分布式对象缓存系统,具有的通用性可用于加快动态 Web 应用程序,减轻数据库负载。 PHP FastCache 把数据库负载到几乎为零,得到更快的页面加载时间的用户,更好的资源利用率。它是简单而强大的。

减少数据库调用

PHP 缓存类数据库:你的网站有 10000 的访问者在线,和你的动态网页必须在每次页加载送 10000 相同的查询数据库。如果使用了 PHP FastCache,你的网页只需要发送 1 个查询数据库,并使用缓存服务处理其他的 9999 个请求给其他游客。

// In your config file
include("phpfastcache/phpfastcache.php");
phpFastCache::setup("storage","auto");

// phpFastCache support "apc", "memcache", "memcached", "wincache" ,"files", "sqlite" and "xcache"
// You don't need to change your code when you change your caching system. Or simple keep it auto
$cache = phpFastCache();

// In your Class, Functions, PHP Pages
// try to get from Cache first. product_page = YOUR Identity Keyword
$products = $cache->get("product_page");

if($products == null) {
	$products = YOUR DB QUERIES || GET_PRODUCTS_FUNCTION;
	// set products in to cache in 600 seconds = 10 minutes
	$cache->set("product_page", $products,600);
}

// Output Your Contents $products HERE

提高缓存和API调用

强大的 PHP 缓存类:你使用 Bing API,谷歌 API 或卷曲你的 API 交换是有限的?PHP FastCache可以节省您的服务器 CPU 和 AP I的交易。你可以使用 PHP FastCache做很容易。

include("phpfastcache/phpfastcache.php");

$cache = phpFastCache("memcached");

// try to get from Cache first.
$results = $cache->get("identity_keyword")

if($results == null) {
	$results = cURL->get("http://www.youtube.com/api/json/url/keyword/page");
	// Write to Cache Save API Calls next time
	$cache->set("identity_keyword", $results, 3600*24);
}

foreach($results as $video) {
	// Output Your Contents HERE
}

获取

官方网站(link:http://www.phpfastcache.com/) | API帮助文档(link:http://www.phpfastcache.com/#document) | 在线示例(link:http://www.phpfastcache.com/#example) | 下载地址(link:http://www.phpfastcache.com/)

城东书院 www.cdsy.xyz
方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门
本栏推荐