php 缓存之 APC 和apcu

时间:2022-12-12 13:11:04

php opcode 缓存 apc.

其实,我自己的理解, php apc 缓存其实分两部分,

  一部分是 缓存 类似于 java 编译的中间的 字节码, 不同于c 语言编译之后的二进制的机器码。 php apc 来缓存php解释器解析

php产生的 opcode, 哈哈。纯属个人的瞎理解,如有错误,请大家指出, 不甚感激。

  还有一部分是 data cache, (key / value map ), 也就是数据缓存, 这点类似于 memerched 和 redis  缓存, 用来存储数据, 将数据库或者文件中的数据暂时缓存起来。以

提高访问速度。

APC的介绍

The Alternative PHP Cache (APC) is a free and open opcode cache for PHP. Its goal is to provide a free, open, and robust framework for caching and optimizing PHP intermediate code.

但是据我查的资料, apc 由于严重的bug ,php官方已经废弃了。 出现了一个 apcu , apcu的接口和apc 是一样的。

这里是一篇介绍的文章,非常不错 https://www.devside.net/wamp-server/installing-apc-for-php-5-5

这篇文章也是相当的好,大家有时间可以看看:https://support.cloud.engineyard.com/hc/en-us/articles/205411888-PHP-Performance-I-Everything-You-Need-to-Know-About-OpCode-Caches

下面是我自己写的测试代码: 注意, 用了一段时间后可能要清除一下缓存,否则会有效率问题, 方法:apc_clear_cache();

<?php
apc_store('name', 'ysr');
$name = apc_fetch('name');
var_dump($name);

  

浏览器访问该页面,是没问题的,输出为:

php 缓存之 APC 和apcu

Installing APC for PHP 5.5 and 5.6

If you need to install and enable the php_apc extension for PHP 5.5 or 5.6, there is a way to accomplish this. But before you do this, there are a few things you have to be aware of:

  1. The last PHP version that had the php_apc extension included in was PHP 5.3. * Newer versions of PHP have replaced APC with php_opcache.
  2. The last APC release was php_apc 3.1.14, and while it worked with PHP 5.5, it was immediately removed due to some serious memory issues that could not be fixed. * php_apc 3.1.14 is not available anywhere, it was removed from all official sources.
  3. The only available release of APC is 3.1.13, and while it’s for both PHP 5.3 and 5.4, it’s only non-beta for 5.3 (i.e., not recommended for PHP 5.4).* php_apc 3.1.13 will not work with PHP 5.5+.

Having said that, APC has two parts to it…

  • The opcode cache part that compiles and caches script code.
  • And the data cache part that stores key/value pairs (e.g., just like memcached).

If your scripts require APC, more than likely they only do so because they use APC’s data cache part. And if you want to run those scripts under PHP 5.5 or 5.6, the APCu extension fully replaces APC, and is fully compatible with APC’s API.

APCu is the APC extension with the opcode cache part removed (which was the source of all APC issues) and the data cache part cleaned up. APCu has the same exact functions and configuration directives as APC – so it can be used as a drop-in replacement.

Also, from what I’ve gathered, APCu performs even better than memcache/memcached on single server setups (which is the case 95% of the time if you are using a WAMP such as WampDeveloper Pro).

Installing APCu For PHP 5.5

1. Download the latest build of APCu from –
http://windows.php.net/downloads/pecl/releases/apcu/

我下载的是

php_apcu-4.0.8-5.4-nts-vc9-x86.zip

For PHP 5.5 Standard:

php_apcu-4.0.7-5.5-ts-vc11-x86.zip

For PHP 5.5 FCGI:

php_apcu-4.0.7-5.5-nts-vc11-x86.zip

2. Extract out files php_apcu.dll and php_apcu.pdb into the proper PHP version package –

For PHP 5.5 Standard:

C:\WampDeveloper\Versions\Php\php-5.5.24.0-r1-win32-vc11-standard\ext\

For PHP 5.5 FCGI:

C:\WampDeveloper\Versions\Php\php-5.5.24.0-r1-win32-vc11-standard-fcgi\ext\

3. Edit php.ini, near end add section:

[APCu]
extension=php_apcu.dll
apc.enabled=1
apc.shm_size=32M
apc.ttl=7200
apc.enable_cli=1
apc.serializer=php

3. Save file. Restart Apache.

php 缓存之 APC 和apcu的更多相关文章

  1. opcache,opcode,apc和apcu的区别

    opcode opcode是php解析器生成的操作码,类似java的字节码,main.class文件. opcache opcache是php的扩展,是一个实现将PHP字节码(OPCode)缓存到共享 ...

  2. php缓存模块apc可能导致php-fpm终止

    如果你的网站出现502错误.同时你网站中又使用了apc模块来做缓存处理.那么这篇文章兴许能帮到你. 首先,查看了php-fpm 的进程数. 发现php-fpm的进程数已经到达了php-fpm.conf ...

  3. yii 缓存之apc

    首先yii CApcCache 实现了一个针对APC的缓存应用组件,常见的缓存操作方法get,set,add,delete,flush... 下面说说配置: 1. 在config/main.php c ...

  4. 使用APC缓存PHP opcode

    1.  关于版本 我的php版本是5.3.10  最开始使用 APC-3.1.8  编译成功,但是 php -m 得不到扩展 , 换成 APC-3.1.9  后解决. 2.  关于配置 apc.cac ...

  5. PHP之APC缓存详细介绍(转)

    1.APC缓存简介 APC,全称是Alternative PHP Cache,官方翻译叫”可选PHP缓存”.它为我们提供了缓存和优化PHP的中间代码的框架. APC的缓存分两部分:系统缓存和用户数据缓 ...

  6. PHP核心代码库中的APC缓存说明123

    1.APC缓存简介APC,全称是Alternative PHP Cache,官方翻译叫”可选PHP缓存”.它为我们提供了缓存和优化PHP的中间代码的框架. APC的缓存分两部分:系统缓存和用户数据缓存 ...

  7. PHP之APC缓存详细介绍

    1.APC缓存简介 APC,全称是Alternative PHP Cache,官方翻译叫"可选PHP缓存".它为我们提供了缓存和优化PHP的中间代码的框架. APC的缓存分两部分: ...

  8. PHP APC缓存配置、使用详解

    一.APC缓存简介 APC,全称是Alternative PHP Cache,官方翻译叫”可选PHP缓存”.它为我们提供了缓存和优化PHP的中间代码的框架. APC的缓存分两部分:系统缓存和用户数据缓 ...

  9. PHP之APC缓存详细介绍&lpar;学习整理&rpar;

    APC的介绍 The Alternative PHP Cache (APC) is a free and open opcode cache for PHP. Its goal is to provi ...

随机推荐

  1. cobbler配置

    :ks脚本关闭pxe,这样就不会重复安装 sed -i 's/pxe_just_once: 0/pxe_just_once: 1/g' /etc/cobbler/settings 6:TFTP服务器 ...

  2. SpringMVC&colon;com&period;mysql&period;jdbc&period;exceptions&period;MySQLSyntaxErrorException&colon; You have an error in your SQL syntax&semi;

    今天用SpringMVC做修改添加操作,之前的操作都实现了添加修改,但始终报com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have ...

  3. Python线性时间排序——桶排序、基数排序与计数排序

    1. 桶排序 1.1 范围为1-M的桶排序 如果有一个数组A,包含N个整数,值从1到M,我们可以得到一种非常快速的排序,桶排序(bucket sort).留置一个数组S,里面含有M个桶,初始化为0.然 ...

  4. AngularJS&lpar;3&rpar;-过滤器

    过滤器可以通过一个管道字符(|)和一个过滤器添加到表达式中.. 1.uppercase/lowercase 大小写过滤器 2.currency过滤器 3.向指令添加过滤器 过滤器可以通过一个管道字符( ...

  5. python--把一个方法变成属性调用

    # coding=utf-8 ''' 装饰器(decorator)可以给函数动态加上功能,对于类的方法,装饰器一样起作用.Python内置的@property装饰器就是负责把一个方法变成属性调用的: ...

  6. c&plus;&plus;链表基本操作

    #include <stdlib.h> #include <malloc.h> #include <stdio.h> typedef struct Node { i ...

  7. 精选 TOP45 值得学习的Python项目

    精选 TOP45 值得学习的Python项目 [导读]热门资源博客 Mybridge AI 比较了 18000 个关于 Python 的项目,并从中精选出 45 个最具竞争力的项目.我们进行了翻译,在 ...

  8. Google C&plus;&plus; 代码规范

    Google C++ Style Guide   Table of Contents Header Files Self-contained Headers The #define Guard For ...

  9. Linux 禁止root 用户登录启用sudo

    1.添加sudo用户执行visudo命令,找到: 复制代码 代码如下: root ALL=(ALL) ALL 在下面增加:(注意,qianyunlai 是Linux新增的一个普通用户),没有的话可创建 ...

  10. iOS-图像之CoreImage框架

    1.coreImage的介绍   coreImage是IOS5中新加入的一个Objective-C的框架,提供了强大高效的图像处理功能,用来对基于像素的图像进行操作与分析.iOS提供了很多强大的滤镜( ...

相关文章