Use APC to cache PHP

Source: Internet
Author: User
Tags apc


. Overview:

Alternative Php Cache (APC) is a free and public php Optimized Code Cache. It is used to provide free, public, and robust architectures to cache and optimize php intermediate code.



1. In Windows, APC requires a temporary path and the Web server has the write permission. It checks the TMP, TEMP, and USERPROFILE environment variables in sequence. If they are not set, use the WINDOWS directory.


2. APC does not support distributed deployment.



II. installation:

Download the PECL dll package from php and put it in the PHP5/ext directory. In fact, the pecl package corresponding to php5.2.5 already contains this file.


III. Configuration

Open php. ini and add the Code:

Extension = php_apc.dll



Apc. enabled = 1

Apc. shm_segments = 1

Apc. shm_size = 64

Apc. max_file_size = 10 M

Apc. stat = 1

IV. Script test:

Restart the Web server and test:

1). Set the entries to be cached.

Store. php

<? Php

$ Bar = 'bar ';

Apc_store ('foo', $ bar );


2). Obtain the cached entries.

Fetch. php

<? Php

Var_dump (apc_fetch ('foo '));


Run store. php and run fetch. php to check the effect.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.