Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is userland caching APCu extension in PHP?

Tags:

php

opcache

Just a question related to OPcache cause I didn't understand it and find an answer on Google:

When we talk about userland caching, what does it mean? I know PHP is pre-bundled with the new Zend OPcache extension and that this extension caches op code into ram in order not to stress too much the processor which should convert to op code the PHP source at every request, but what about the APCu when they say that it implements userland caching?

What is userland caching? Is it possible to keep APCu and Zend OPcache together, or not? Should Zend OPcache be used instead of APCu?

like image 385
tonix Avatar asked Nov 29 '14 18:11

tonix


People also ask

What is APCu in PHP?

APCu is an in-memory key-value store for PHP. Keys are of type string and values can be any PHP variables. APCu only supports userland caching of variables. APCu is APC stripped of opcode caching. The first APCu codebase was versioned 4.0.

What is APCu extension?

The APCu extension adds object caching functions to PHP. APCu is the official replacement for the outdated APC extension. APC provided both opcode caching (opcache) and object caching. As PHP versions 5.5 and above include their own opcache, APC was no longer compatible, and its opcache functionality became useless.


1 Answers

APCu was really developed by Joe Watkins in response to OPcache. APC supports both opcode caching and data caching, but has been dogged with stability problems in support opcode caching since PHP 5.4. After Zend Inc opened the source of Opcache and placed it under the PHP licence, it became the core and preferred opcode cache from PHP 5.5. But it only supports opcode caching and not data caching.

Joe's APCu is in essence a stripped out version of APC that only includes the data caching code, and is designed to be used along side OpCache if you need data caching.

Note that whereas Opcode caching is transparent at a source code level, data caching is not. Your application needs to be coded explicitly to use it. (Though standard PHP apps such as Wordpress, Drupal, phpBB, MediaWiki, ... include this support by default).

like image 162
TerryE Avatar answered Sep 19 '22 00:09

TerryE