What to use instead of apc user data cache in php 5.5?

m6k picture m6k · Jun 28, 2013 · Viewed 7.5k times · Source

PHP 5.5 includes zend opcache by default, which basically means that almost nobody will use APC.

But what to use instead of the user data cache part of APC (apc_store & apc_fetch & similar)?

One use case where I really like to use APC user data cache are "versions" of static assets (javascript, css..). Whenever I reference static file, I add hash of its content into the url (e.g. <script src=/script.js> will became <script src=/script.js?v=hash>), so that browser always uses current version and can cache it permanently.

I can imagine using redis or memcache to store the hashes of static files, but it seems silly to ask another process over network or socket just to get a hash of file content. APC user data cache (which is in shared memory and accessing it is almost as fast as accesing php variable) seems just the right thing to use for such data.

So the question is: what to use in php 5.5 to cache small bits of data instead of APC?

Answer

Artur Bodera picture Artur Bodera · Jan 9, 2014

Starting from PHP 5.5 the APC user data storage is packaged separately as PECL APCu.

This allows you to use all user cache functions, such as apc_store(). It will also return true for extension_loaded('apc') - this means that all libraries depending on APC will work similarly to PHP 5.4.