0

i have apc.enable_cli=1 in php.ini for cli;

i tested sharing variables with apc with this script:

<?php
$apctest=apc_fetch('apctest');
echo "apctest was " . $apctest;
echo "\n";
if($argc>1){
    $newval=$argv[1];
}else{
    $newval='ok';
}
echo "setting apctest to " . $newval;
echo "\n";
apc_store('apctest',$newval);
sleep(30);

i runned it with

php test_cli_apc.php > /dev/null &

and then within 30 seconds runned

php test_cli_apc.php

but it has outputted "apctest was " , not "apctest was ok"

i have tried same script with "apc" changed to "apcu" but it also does not work in same way.

2
  • 1
    AFAIK APC is only there within the server whilst it is running. So if you run separate CLI's then the values will not persist. Use something like memcache which is an external cache. Commented Jul 16, 2017 at 14:22
  • 1
    Just because a cli process is running, doesn't mean you can run another cli instance and read APC variables. A cli process shares no state or memory with other cli processes. So APC is of no value in CLI processes. Commented Jul 16, 2017 at 19:35

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.