tags:

views:

22

answers:

1

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.

+1  A: 

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:

  1. Using memcached instead of APC, which is accessible from anywhere, not just a single apache instance
  2. 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.
Frank Farmer
Awesome! Thanks for the quick response.
Jared