apc_delete() not working in background script
I have a shell background convertor on my video website and I can't seem to get APC to delete a key as a file is uploaded and its visibility is updated. The script is structured like so:
if(file_exists($output_file))
{
$conn->query("UPDATE `foo` SET `bar` = 1 WHERE `id` = ".$id." LIMIT 1");
apc_delete('feed:'.$id);
}
Everything works fine except for the APC and this is the开发者_运维问答 only script on the site that has had this problem. I'm stumped.
You can't access the APC shared memory segment inside of apache from a process external to apache. If you enable APC in CLI mode, CLI scripts simply receive their own shared memory segments.
You can work around this by:
- Using memcached instead of APC, which is accessible from anywhere, not just a single apache instance
- Exposing a URL (e.g. http://example.com/delete.php?id=5) which you can call from your CLI script. The URL will be processed by a script inside of apache, and as such, have access to APC.
精彩评论