PHP cache for APC and APCU

Source: Internet
Author: User
Tags apc apcu

PHP opcode caches APC.

In fact, my own understanding, PHP APC Cache actually divided into two parts,

Part of the cache is similar to the Java compilation of the intermediate bytecode, different from the C language compiled binary machine code. PHP APC to cache PHP interpreter parsing

PHP produced by opcode, haha. Purely personal blind understanding, if there are errors, please point out, not very grateful.

Also part of the data cache, (Key/value map), which is the datastore, is similar to memerched and Redis caches, which are used to store data and temporarily cache data in a database or file. To

Improve access speed.

Introduction of APC

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

However, according to my data, APC due to serious bugs, the official PHP has been abandoned. A APCU appears, and the APCU interface is the same as the APC.

Here is an article of introduction, very good

This article is also quite good, we have time to look at: Php-performance-i-everything-you-need-to-know-about-opcode-caches

Here are my own test code: Note that after a period of time may have to clear the cache, otherwise there will be efficiency problems, method: Apc_clear_cache ();

<?phpapc_store (' name ', ' YSR '); $name = Apc_fetch (' name '); Var_dump ($name);


Browser access to this page, is no problem, the output is:

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-to-accomplish this. But before there is a few things you has to be aware of:

    1. The last PHP version this had the PHP_APC extension included in is PHP 5.3. * Newer versions of PHP has replaced APC with Php_opcache.
    2. The last APC release is PHP_APC 3.1.14, and while it worked with PHP 5.5, it is immediately removed due to some serious Memory issues that could is fixed. * PHP_APC 3.1.14 is isn't available anywhere, it was removed from all official sources.
    3. The only available release of APC was 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., no T recommended for PHP 5.4). * PHP_APC 3.1.13 won't work with PHP 5.5+.

Had said that, APC had the parts to it ...

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

If your scripts require APC, more than likely they the only doing 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 were the source of all APC issues) and the data cache P Art cleaned up. APCU has the same exact functions and configuration directives as apc–so it can used as a drop-in replacement.

Also, from what I've gathered, APCU performs even better than memcache/memcached on single server setups (which are the CAs e 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–

I downloaded it.

For PHP 5.5 standard:

For PHP 5.5 FCGI:

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

For PHP 5.5 standard:


For PHP 5.5 FCGI:


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


3. Save file. Restart Apache.

PHP cache for APC and APCU

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.