php cache种类,phpFastCache

软件简介

phpFastCache 是一个开源的 PHP 缓存库,只提供一个简单的 PHP 文件,可方便集成到已有项目,支持多种缓存方法,包括:apc,

memcache, memcached, wincache, files, pdo and mpdo。可通过简单的 API 来定义缓存的有效时间。

示例代码:

// 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

}

?>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值