PHP缓存集成库phpFastCache用法
《PHP缓存集成库phpFastCache用法》要点: PHP应用本篇章节讲解PHP缓存集成库phpFastCache用法.分享给大家供大家参考.具体分析如下: phpFastCache是一个开源的PHP缓存库,只提供一个简单的PHP文件,可方便集成到已有项目,支持多种缓存办法,包括:apc,memcache,memcached,wincache,files,pdo and mpdo.可通过简单的API来定义缓存的有效时间.
代码如下:
<?php
// In your config file include("phpfastcache/phpfastcache.php"); phpFastCache::setup("storage","auto"); // phpFastCache support "apc","memcache","memcached","wincache","files","sqlite" and "xcache" // In your Class,Functions,PHP Pages if($products == null) { // Output Your Contents $products HERE 提高cURL和API调用性能
代码如下:
<?php
include("phpfastcache/phpfastcache.php"); $cache = phpFastCache("memcached"); // try to get from Cache first. if($results == null) { foreach($results as $video) { 全页缓存
代码如下:
<?php
// use Files Cache for Whole Page / Widget // keyword = Webpage_URL if($html == null) { ??? // GET HTML WEBPAGE echo $html; 挂件缓存
代码如下:
<?php
// use Files Cache for Whole Page / Widget $cache = phpFastCache("files"); $html = $cache->widget_1; if($html == null) { echo or return your $html; 同时使用多种缓存
代码如下:
<?php
// in your config files include("phpfastcache/phpfastcache.php"); // auto | memcache | files ...etc. Will be default for $cache = __c(); phpFastCache::$storage = "auto"; $cache1 = phpFastCache(); $cache2 = __c("memcache"); $cache3 = new phpFastCache("apc"); // How to Write? // How to Read? // Free to Travel between any caching methods $cache1 = phpFastCache("files"); $cache2 = __c("apc"); $data = __c("memcache")->get("keyword1"); // Multiple ? No Problem $list = $cache1->getMulti(array("key1","key2","key3")); $list = $cache1->apc->getMulti(array("key1","key3")); // want more? Check out document in source code 希望本文所述对大家的PHP程序设计有所赞助. 编程之家培训学院每天发布《PHP缓存集成库phpFastCache用法》等实战技能,PHP、MYSQL、LINUX、APP、JS,CSS全面培养人才。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |