Serve one client at a time
<p>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.</p>

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

<p>I tried to use <code>apc</code> then, putting together this code:</p>

<pre><code>&lt;?php

  while (apc_fetch('foo')) {
    echo "waiting...\n";
    sleep(1);
  }

  $foo = true;
  apc_store('foo', $foo);

  echo "results.";
  sleep(10);

  apc_delete('foo');

?&gt;
</code></pre>

<p>but if I open twice this page, what I see is just <code>results.</code> in both. I was expecting to read some <code>waiting...</code> as well, since when I load the page for the second time, the first one should have set <code>foo</code> to <code>true</code>.</p>

<p>Is this a legit (but mistaken) use of <code>apc</code>? Am I using the wrong tool?</p>
