We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

APC on PHP 5.6+ doubts

Hello,

I read about APC, and noticed that it's is confusing if it is still supported on PHP 5.6+ versions. Some peope say that PHP since version 5.5+ has the extension opcache, which is not the same thing as APC.

They say that exists the APC and APCu, which I though that was the newer version of APC. Is that right ?

I'm using ubuntu 14.04 and instaled PHP APC using apt-get install php-apc which instaled some sort of emulated APC, that was what phpinfo() shown.

I want to use a cache capability on my application to store a big array of strings.

Will the PHP APC still a supported and default way to chache data on PHP newer versions ?

Thankyou.

I don't know whether APC is supported on 5.6+, but I can tell you why you don't need it.

OPCache basically does the same thing as apc, except OPCache does it automatically. From the PHP manual:

OPcache improves PHP performance by storing precompiled script bytecode in shared memory, thereby removing the need for PHP to load and parse scripts on each request.


so what you would normally have to manually c ode in with apc, is done for you by OPCache.

I don't know whether APC is supported on 5.6+, but I can tell you why you don't need it.

OPCache basically does the same thing as apc, except OPCache does it automatically. From the PHP manual:

OPcache improves PHP performance by storing precompiled script bytecode in shared memory, thereby removing the need for PHP to load and parse scripts on each request.


so what you would normally have to manually c ode in with apc, is done for you by OPCache.

So APC Support for phalcon will be removed in the future ? Since OPCache can actually be better ? I noticed that what I need is APCu which I'm using to store custom data.

I'm using something like this:

$frontCache = new \Phalcon\Cache\Frontend\Data(array(
    'lifetime' => 86400
));
$this->cache = new \Phalcon\Cache\Backend\Apc($frontCache, array(
    'prefix' => 'translation'
));

With OPCode I can cache a script which references an array of strings ? How can I execute a cached script using opcode (since opcode don't executes the script, only loads, compilles and executes)?



7.9k

OPcache is cache your php byte code, so each request php engine dont need to recompile php script to byte code, the rade off if you change your script you have restart webserver or php-fpm. IIRC APCu is drop in replacement for APC, so you can cache your custom data that available on every request

thats exactly right. however, it may not provide much of a boost in terms of performance (unless its an expensive database call that you're cacheing the result for.)



145.0k
Accepted
answer
edited Feb '16

Instead of APC install APCu, im using it on php7, from some php version you have built-in opcache so you only need user apc to store data for example.

Yeah @Jurigag, installing APCu solved for me. I installed APCu many days ago. I read that APCu still supported by PECL.You answered well my questions =). Thanks

Instead of APC install APCu, im using it on php7, from some php version you have built-in opcache so you only need user apc to store data for example.

I always vote for Memcached if you need app-level cache.