APCu doesn't store in PHP 7
Asked Answered
A

1

5

APCu will only fetch values that were stored in the current page load.

Refreshing this twice:

<?php 
var_dump(apcu_fetch("test"));

apcu_store("test", "works", 3600);
var_dump(apcu_fetch("test"));
?>

outputs the following:

bool(false) string(5) "works"

So it stores the data while the current page is loading. After that it doesn't exist anymore...

I'm using the latest stable version (5.1.2) with the default configuration on PHP 7.0.0.

I've tried different versions of APCu and PHP 7. Also can't find anything similar on Google...

This is my PHP apcu configuration: Broken APCu configuration

Asymmetric answered 16/12, 2015 at 20:0 Comment(7)
Do you have opcache enabled?Varini
@Andrea OPcache is designed to replace the APC module, it is not possible to run them in parallel in PHPRefrigerate
Zend OPcache is up & running. Disabling it gives the same result.Asymmetric
Added a photo with the configuration.Asymmetric
@limonte this is APCu, not APCVarini
What processing model are you using ? (ie mod_php, fpm, fcgi, something else)Ugrian
I'm using CGI/FastCGI.Asymmetric
U
10

APC(u) is intended to function in a prefork multiprocess, or multithreaded SAPI.

FastCGI (without FPM) and CGI are not prefork models, they spawn distinct processes, as such APC(u) will not work correctly in those environments.

Nor will anything that uses shared mapped memory, like Opcache: They can cache for the current process, but share they cannot.

Ugrian answered 17/12, 2015 at 7:57 Comment(2)
Is there a warning on the site about this? Maybe APCu should refuse to load in those SAPIs, like pthreads does.Varini
I'll discuss it with other maintainers ... or anyone who wants to say anything ... github.com/krakjoe/apcu/issues/161Ugrian

© 2022 - 2024 — McMap. All rights reserved.