I am trying to use apc_store to store a token variable that would continously change, thus need to be created by one php script, and accessed by another php script.
Environment: PHP: version 7.3 OS: Ubuntu 18.04
References followed:
Stackoverflow: Troubleshooting apc_store
Installation procedure:
sudo apt-get install php-apcu
sudo apt-get install php-apcu-bc
Installation result:
php-apcu is already the newest version (5.1.18+4.0.11-1+ubuntu18.04.1+deb.sury.org+1).
php-apcu-bc is already the newest version (1.0.5-1+ubuntu18.04.1+deb.sury.org+20191129).
The problem
Even though I do not get an error message, the system will not return expected result, e.g. the string "abc", further on the result indicates "bool(false)" which should be "bool(true)".
Question:
How can I get the result to show?:
string(3) "abc"
Other tests I tried to change /etc/php/7.0/mods-available/apcu-ini to
extension=apcu.so
extension=apc.so
...giving the error:
PHP Warning: Module 'apc' already loaded in Unknown on line 0
My php script:
<?php
$token = "abc";
apc_store('token_1', $token);
var_dump(apc_fetch('token_1'));
Result:
bool(false)
Expected result:
string(3) "abc"
Troubleshooting:
Checking apc:
Result:
$ php -i | grep apc
/etc/php/7.3/cli/conf.d/20-apcu.ini,
/etc/php/7.3/cli/conf.d/25-apcu_bc.ini
apc
apcu
apc.coredump_unmap => Off => Off
apc.enable_cli => Off => Off
apc.enabled => On => On
apc.entries_hint => 4096 => 4096
apc.gc_ttl => 3600 => 3600
apc.mmap_file_mask => no value => no value
apc.preload_path => no value => no value
apc.serializer => php => php
apc.shm_segments => 1 => 1
apc.shm_size => 32M => 32M
apc.slam_defense => Off => Off
apc.smart => 0 => 0
apc.ttl => 0 => 0
apc.use_request_time => On => On
php -i | grep apc? I am guessing you have: apc.enable_cli => Off => Off - matiit