How can I get PHP to use the same APC cache when i

2019-06-15 13:15发布

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?

4条回答
相关推荐>>
2楼-- · 2019-06-15 13:21

you would need a web server written in php -- the APC cache is shared only by forked child processes. If you had a php webserver, you could start a master cli, init apc, fork and load/run the web server in one child process, and fork and run your php cli script in another. Kind of a gross hack, huh. Fork and require(), I don't think the apc cache would survive an exec()

查看更多
ゆ 、 Hurt°
3楼-- · 2019-06-15 13:25

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?

查看更多
Summer. ? 凉城
4楼-- · 2019-06-15 13:26

call your CLI as a CGI /path-to/cgi-sys/php5.cgi /home/name/crons/engine.php

查看更多
Viruses.
5楼-- · 2019-06-15 13:39

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....

查看更多
登录 后发表回答