I need to put on a php script that has to serve only one request at a time. That is, if a user requests the page, it must not serve him until a previous request is not completely handled.
I would play with application variables in order to accomplish that, but I see that php doesn't have anything like that, if I well understood.
I tried to use apc
then, putting together this code:
<?php
while (apc_fetch('foo')) {
echo "waiting...\n";
sleep(1);
}
$foo = true;
apc_store('foo', $foo);
echo "results.";
sleep(10);
apc_delete('foo');
?>
but if I open twice this page, what I see is just results.
in both. I was expecting to read some waiting...
as well, since when I load the page for the second time, the first one should have set foo
to true
.
Is this a legit (but mistaken) use of apc
? Am I using the wrong tool?