Home > php教程 > php手册 > body text

使用APC缓存PHP

WBOY
Release: 2016-06-13 10:43:19
Original
1183 people have browsed it

 

. 概述:

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,看看效果。

Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!