Home  >  Article  >  php教程  >  使用APC缓存PHP

使用APC缓存PHP

WBOY
WBOYOriginal
2016-06-13 10:43:191180browse

 

. 概述:

Alternative Php Cache(APC)是php 的一个免费公开的优化代码缓存。它用来提供免费,公开并且强健的架构来缓存和优化php 的中间代码。

 

注:

1. 在Windows下,APC需要有一个临时路径,并且Web服务器具有可写权限。它按顺序检查TMP、TEMP、USERPROFILE环境变量,如果发现他们都没有设置,最后就使用WINDOWS目录。

 

2. APC不支持分布式。

 

 

II. 安装:

从pecl4win.net.php下载PECL dll包,放到PHP5/ext目录下。实际上php5.2.5对应的pecl包已经包含此文件。

 

III. 配置

打开php.ini,加入代码:

extension=php_apc.dll

 

[APC]

apc.enabled = 1

apc.shm_segments = 1

apc.shm_size = 64

apc.max_file_size = 10M

apc.stat=1

IV. 脚本测试:

重新启动Web服务器,测试:

1). 设置要缓存的条目。

store.php

   

      $bar = 'BAR'; 

      apc_store('foo', $bar); 

    ?> 

2). 取得缓存的条目。

fetch.php

  var_dump(apc_fetch('foo')); 

?> 

运行store.php,然后运行fetch.php,看看效果。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:实现简单的ACLNext article:PHP常用的几种缓存机制