4.3. Zend_Cache前端

4.3.1. Zend_Cache_Core

4.3.1.1. 简介

Zend_Cache_Core是一个特别的前端,因为他是模块的核心. 它是一个一般化(generic)的缓存前端,并且由其他类扩展.

4.3.1.2. 可用选项
这些选项被传递给如前面例子中演示的工厂方法.


4.3.1.3. 例子
An example is given in the manual at the very beginning.

如果你只向缓存中存储字符串(由于”automatic_serialization”选项,可能会存储一些布尔值),你可以使用更加简介的构造:

<?php
// we assume you already have $cache$id = 'myBigLoop'; // cache id of "what we want to cache"if (!($data = $cache->load($id))) {// cache miss$data = '';for ($i = 0; $i < 10000; $i++) {$data = $data . $i;}$cache->save($data);}// [...] do something with $data (echo it, pass it on etc.)

如果你缓存多个块或则数据实例,意思是一样的:

<?php
// make sure you use unique identifiers:
$id1 = 'foo';
$id2 = 'bar';// block 1
if (!($data = $cache->load($id1))) {// cache missed$data = '';for ($i=0;$i<10000;$i++) {$data = $data . $i;}$cache->save($data);}
echo($data);// this isn't affected by caching
echo('NEVER CACHED! ');// block 2
if (!($data = $cache->load($id2))) {// cache missed$data = '';for ($i=0;$i<10000;$i++) {$data = $data . '!';}$cache->save($data);}
echo($data);

如果你想缓存特殊值(带 “automatic_serialization” 选项的布尔值)或不能用上述紧缩结构的空字符串,你需要正式地测试缓存记录。

<?php// the compact construction (not good if you cache empty strings and/or booleans)
if (!($data = $cache->load($id))) {// cache missed// [...] we make $data$cache->save($data);}// we do something with $data// [...]// the complete construction (works in any case)
if (!($cache->test($id))) {// cache missed// [...] we make $data$cache->save($data);} else {// cache hit$data = $cache->load($id);}// we do something with $data

4.3.2. Zend_Cache_Frontend_Output

4.3.2.1. 简介
Zend_Cache_Frontend_Output 是一个输出捕捉前端.它在PHP中使用输出缓冲捕获start() 和 end() 方法间的一切输出.

4.3.2.2. 可用的选项
该前端除了Zend_Cache_Core那些选项外没有任何特定的选项.

4.3.2.3. 例子
An example is given in the manual at the very beginning. Here it is with minor changes:

<?php
// if it is a cache miss, output buffering is triggered
if (!($cache->start('mypage'))) {// output everything as usualecho 'Hello world! ';echo 'This is cached ('.time().') ';$cache->end(); // output buffering ends}echo 'This is never cached ('.time().').';

Using this form it is fairly easy to set up output caching in your already working project with little or no code refactoring.


4.3.3. Zend_Cache_Frontend_Function

4.3.3.1. Introduction
Zend_Cache_Frontend_Function caches the results of function calls. It has a single main method named call() which takes a function name and parameters for the call in an array.

4.3.3.2. A可用的选项
表 4.2. 函数前端选项

4.3.3.3. 例子
在PHP中使用 call() 函数于使用 call_user_func_array()相同:

<?php
$cache->call('veryExpensiveFunc', $params);# $params is an array
# for example to call (with caching) veryExpensiveFunc(1, 'foo', 'bar'), you will use
# $cache->call('veryExpensiveFunc', array(1, 'foo', 'bar'))

7.2.Zeng_Cache(3) --- 前端相关推荐

  1. etcd 笔记(02)— etcd 安装(apt 或 yum 安装 、二进制包安装、Docker 安装 etcd、etcd 前端工具etcdkeeper)

    1. 使用 apt 或 yum 安装 etcd 命令如下: sudo apt-get install etcd 或者 sudo yum install etcd 这样安装的缺点是:安装的 etcd 版 ...

  2. 【牛腩新闻发布系统】开始前端03

    前言: 后台代码写好后,开始按照设计实现前端,之前有做过关于网页的东西,不过是用Dreamweaver做的静态,不能实现和数据库的交互,如果只是单纯学界面设计的话,用Dreamweaver容易上手,在 ...

  3. LLVM Clang前端编译与调试

    LLVM Clang前端编译与调试 iOS 关于编译 o 一.Objective-C 编译过程 o 为什么需要重新编译? o 编译步骤 o 二.编译步骤的详细说明 o 1.预处理 o 2.编译 o 词 ...

  4. Clang:LLVM 的 C 语言家族前端

    Clang:LLVM 的 C 语言家族前端 Clang 项目为LLVM 项目的 C 语言家族(C.C++.Objective C/C++.OpenCL.CUDA 和 RenderScript)中,提供 ...

  5. TensorFlow Frontend前端

    TensorFlow Frontend前端 TensorFlow前端有助于将TensorFlow模型导入TVM. Supported versions: • 1.12 and below Tested ...

  6. Clang:LLVM的C语言家族前端

    Clang:LLVM的C语言家族前端 Clang项目为LLVM 项目的C语言家族(C,C ++,Objective C / C ++,OpenCL,CUDA和RenderScript)中的语言提供了语 ...

  7. 前端的单页面模式和多页面模式

    一.前言 前端部分的搭建,需要考虑使用哪种模式进行页面之间的跳转交互, 而项目内的页面交互,不可避免的需要相互之间的数据共享. 这就引出了本篇博客的目的,一起来谈谈:项目前端部分的构建方式以及数据共享 ...

  8. JavaScript—— 前端编程语言

    JavaScript 前端编程语言   http://caibaojian.com/javascript/ 转载于:https://www.cnblogs.com/highpointengineer/ ...

  9. day44前端开发1之html基础

    web前端开发1 一.前端三剑客之html  1.为标记语言,是非编程语言  2.自身不具备逻辑,遇到负责重复操作只能全部手写(Ctrl+C > V)  3.组成:标签, 指令, 实体  标签: ...

  10. 转 前端工程师凭什么这么值钱?

    [CSDN编者按]前端工程师的薪资之高是业界公认的事实,但是很多人会质疑前端工程师,认为他们并不能称为软件工程师,也"配不上"高昂的报酬.本文的作者分享了自己从一个前端菜鸟成长为一 ...

最新文章

  1. 基于BP神经网络+HOG特征提取的视频中车辆车牌识别算法仿真
  2. C++STL常用算术生成算法
  3. python接口自动化(三十四)-封装与调用--函数和参数化(详解)
  4. ES6学习(八)—Promise对象 超鸡重要
  5. php的Allowed memory size of 134217728 bytes exhausted问题解决办法
  6. 让Node.js在Azure上运行-3
  7. linux用户个人的环境变量,linux下的变量以及系统和个人环境变量的配置文件
  8. Fehelper 下载、安装与使用
  9. 2020千月最新影视源码 对接苹果影视app小白零基础搭建视频教学可赚钱影视APP
  10. 百度搜索移动端流量词热度统计方法
  11. 小程序设置按钮分享功能
  12. 废话文学顶流之文章生成器
  13. 【原】制造垃圾邮件设想【未尝试】
  14. 布莱叶盲文-谷歌生态
  15. vue中 this.$set的使用
  16. yii mysql gii_Yii2.0开发——使用Gii生成代码的简单实践
  17. 两种方法用宏定义写出swap(x,y)
  18. 如何在Oracle中检测和修复块损坏
  19. python花猫_涨见识了,在终端执行 Python 代码的 6 种方式!
  20. Type-c快充加无线直播麦克风方案(无线麦克风边充电)LDR6023C专业快充芯片

热门文章

  1. AngularJS的学习--ng-show/ng-hide/ng-if和ng-switch
  2. Android 一些笔记(这只是一些个人笔记)
  3. php $GLOBALS 超全局变量的理解
  4. 未在本地计算机上注册“microsoft.ACE.oledb.12.0”提供程序报错的解决办法
  5. 懒加载的3种实现方式
  6. 机器学习(一):数据预处理
  7. centos 6 编译emacs-24.5
  8. Python 实现数据结构中的单链表,循环单链表,双链表
  9. Exchange 2016通过IIS限制不允许访问OWA的域名或网段
  10. opencv python 鼠标响应操作