Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get PHP to use the same APC cache when invoked on the CLI and the web?

I'm using APC to cache user variables (with the apc_store/apc_fetch commands). I've also enabled APC for the CLI with the option "apc.enable_cli = 1". However, the CLI version of PHP seems to access a different APC cache from the version used by Apache.

Is it possible to configure APC to use the same cache for both CLI and web invocations?

like image 378
Ben Dowling Avatar asked Jan 13 '09 15:01

Ben Dowling


2 Answers

Not possible.. The only way to accomplish something like what your asking is to use something like memcacheD. Or run what you need to run through your webserver. What's running CLI that you cannot run via a web script with a cronjob?

like image 54
DreamWerx Avatar answered Oct 06 '22 00:10

DreamWerx


You can use shm. This technology lend to access to Unix Shared memory. You can put some variable in shm and then in another scritp, even programmed in another languaje you can get the shared variables.

shm_put_var and shm_get_var.

It's slower than APC, but it's faster than memcached, redis, etc.

I hope It will help you, and I'm sorry for my English....

like image 30
Teruel Avatar answered Oct 05 '22 22:10

Teruel