码迷,mamicode.com
首页 > Web开发 > 详细

php缓存相关

时间:2014-08-13 18:20:26      阅读:260      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   os   io   文件   ar   cti   

在php运行期间,php引擎要对php源码进行处理,(词法分析,语法分析等)然后生成opcode。

然后再运行。在这个阶段可以把opcode缓存起来,当下次需要运行这段程序的时候,就避免了再次 进行词法分析,语法分析,直接拿opcode来用。

eAccelerator就是这样的程序。

 

vld查看php的opcode:

http://pecl.php.net/package/vld/0.12.0/windows

在上面的地址下载vld,解压后 将 php_vld.dll,拷贝到ext目录下。

修改php.ini,增加“extension=php_vld.dll”;

要查看opcode,新建一个php脚本,cmd下执行

“E:\xampp\php>php -dvld.active=1 e:\htdocs\mytest\n.php”命令。

显示结果:

E:\xampp\php>php -dvld.active=1 e:\htdocs\mytest\n.php
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = 13, Position 2 = 6
Branch analysis from position: 13
Return found
Branch analysis from position: 6
Jump found. Position 1 = 3
Branch analysis from position: 3
Jump found. Position 1 = 1
Branch analysis from position: 1
filename:       E:\htdocs\mytest\n.php
function name:  (null)
number of ops:  14
compiled vars:  !0 = $i
line     # *  op                           fetch          ext  return  operands
---------------------------------------------------------------------------------
  30     0  >   ASSIGN                                                   !0, 0
         1  >   IS_SMALLER                                       ~1      !0, 100
         2    > JMPZNZ                                        6          ~1, ->13
         3  >   POST_INC                                         ~2      !0
         4      FREE                                                     ~2
         5    > JMP                                                      ->1
  31     6  >   CONCAT                                           ~3      ‘a‘, !0
         7      FETCH_W                      local               $4      ~3
         8      ASSIGN                                                   $4, !0
  32     9      CONCAT                                           ~6      ‘a‘, !0
        10      FETCH_R                      local               $7      ~6
        11      ECHO                                                     $7
  33    12    > JMP                                                      ->3
  36    13  > > RETURN                                                   1

branch: #  0; line:    30-   30; sop:     0; eop:     0; out1:   1
branch: #  1; line:    30-   30; sop:     1; eop:     2; out1:  13; out2:   6
branch: #  3; line:    30-   30; sop:     3; eop:     5; out1:   1
branch: #  6; line:    31-   33; sop:     6; eop:    12; out1:   3
branch: # 13; line:    36-   36; sop:    13; eop:    13
path #1: 0, 1, 13,
path #2: 0, 1, 6, 3, 1, 13,
012345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
6566676869707172737475767778798081828384858687888990919293949596979899

安装eAccelerator:

下载:http://www.sitebuddy.com/php/accelerators/eaccelerator-windows-binaries

下载下来的文件解压后,将dll文件,贝到ext下

修改php.ini,开启

    [eAccelerator]
    zend_extension_ts="C:/php/ext/eaccelerator.dll"       //路径根据实际情况而定
    eaccelerator.shm_size="32"       //根据系统内存来定,默认16M,可以改成64M
    eaccelerator.cache_dir="C:/php/temp"     //前面创建的缓冲文件夹
    eaccelerator.enable="1"
    eaccelerator.optimizer="1"
    eaccelerator.check_mtime="1"
    eaccelerator.debug="0"
    eaccelerator.filter=""
    eaccelerator.shm_max="0"
    eaccelerator.shm_ttl="0"
    eaccelerator.shm_prune_period="0"
    eaccelerator.shm_only="0"
    eaccelerator.compress="1"
    eaccelerator.compress_level="9"

配置redis:

下载http://www.redis.cn/download.html

解压后有两个dll文件,全部拷贝到ext目录下。[我拷贝到ext,还提示找不到。最后拷贝到php.exe目录下才不再报错]。

修改php.ini

添加

"extension=php_igbinary.dll

 extension=php_vld.dll"

重启apache,phpinfo();可以查看是否启动。

 

测试redis:

$redis = new Redis();  
$redis->connect("192.168.0.110","6379");  //php客户端设置的ip及端口  
//存储一个 值  
$redis->set("say","Hello World");  
echo $redis->get("say");     //应输出Hello World  
  
//存储多个值  
$array = array(‘first_key‘=>‘first_val‘,  
          ‘second_key‘=>‘second_val‘,  
          ‘third_key‘=>‘third_val‘);  
$array_get = array(‘first_key‘,‘second_key‘,‘third_key‘);  
$redis->mset($array);  
var_dump($redis->mget($array_get));  

 

 

 

php缓存相关,布布扣,bubuko.com

php缓存相关

标签:style   blog   http   os   io   文件   ar   cti   

原文地址:http://www.cnblogs.com/simpman/p/3910497.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!