title: memcached persistence in PHP does not work as expected
body: <p>i have played a bit around with different memcached library and plugin version to enable real persistence between PHP memcache client and memcached server.</p>
  
  <p>The problem is that still connections are opened and closed so that the connection counter goes up instead of the reusage of a existing persistent connection.</p>
  
  <p>I have compiled the memcached daemon on from newest source on a redhat machine. 
  I use the version memcached-1.4.14 and started with "#/opt/memcached/bin/memcached -vvvv"</p>
  
  <p>The php plugin i have also compiled from newest source version memcached-2.0.1, i have compiled it against libmemcached-1.0.9 to have it up to date. Currently it does not compile against libmemcached-1.0.10.</p>
  
  <p>My PHP script looks like this:</p>
  
  <pre><code>&lt;?php
  header("Cache-Control: no-cache, must-revalidate");
  header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
  
  $key = "key_" . uniqid();
  $memcached = new Memcached( 'persistent' );
  $memcached-&gt;setOption(Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
  $memcached-&gt;setOption(Memcached::OPT_RECV_TIMEOUT, 1000);
  $memcached-&gt;setOption(Memcached::OPT_SEND_TIMEOUT, 3000);
  $memcached-&gt;setOption(Memcached::OPT_TCP_NODELAY, true);
  $memcached-&gt;setOption(Memcached::OPT_PREFIX_KEY, 'persistent');
  
  if( !count($memcached-&gt;getServerList() ) )
  {
      $memcached-&gt;addServer( 'localhost', 11211 );
  }
  $memcached-&gt;set($key, 'value');
  $value = $memcached-&gt;get($key);
  
  print_r( $memcached-&gt;getStats() );
  ?&gt;
  </code></pre>
  
  <p>On firing the script i see in the output that servers are not added, only after timeout period.</p>
  
  <pre><code>Array ( [@�qVG:11211] =&gt; Array ( [pid] =&gt; 3728 [uptime] =&gt; 73 [threads] =&gt; 4 [time] =&gt; 1343813688 [pointer_size] =&gt; 64 [rusage_user_seconds] =&gt; 0 [rusage_user_microseconds] =&gt; 6998 [rusage_system_seconds] =&gt; 0 [rusage_system_microseconds] =&gt; 31995 [curr_items] =&gt; 37 [total_items] =&gt; 37 [limit_maxbytes] =&gt; 67108864 [curr_connections] =&gt; 38 [total_connections] =&gt; 47 [connection_structures] =&gt; 39 [bytes] =&gt; 3589 [cmd_get] =&gt; 37 [cmd_set] =&gt; 37 [get_hits] =&gt; 37 [get_misses] =&gt; 0 [evictions] =&gt; 0 [bytes_read] =&gt; 3267 [bytes_written] =&gt; 39458 [version] =&gt; 1.4.14 ) )
  </code></pre>
  
  <p>But the connection counter still goes up and i suppose that the client creates a connection and on server side the persistent connection is re-used. </p>
  
  <pre><code>#netstat -an | grep 11211 | wc -l
  
  tcp        0      0 ::1:11211                   ::1:55941                   VERBUNDEN   
  tcp        0      0 ::1:55961                   ::1:11211                   VERBUNDEN   
  tcp        0      0 ::1:55959                   ::1:11211                   VERBUNDEN   
  tcp        0      0 ::1:11211                   ::1:56005                   VERBUNDEN   
  ...and so on
  </code></pre>
  
  <p>On server side i get verbous output that tells me that persistence is used:</p>
  
  <pre><code>...
  &lt;43 get persistentkey_5018f83903ded
  &gt; FOUND KEY persistentkey_5018f83903ded
  &gt;43 sending key persistentkey_5018f83903ded
  &gt;43 END
  ...
  </code></pre>
  
  <p>We want to use memcache on a high performance environment with a lot of incomming connections, and the connection amout does kill the apache childs currently. Any ideas how to enable real persistence?</p>
  
  <p>Used software:</p>
  
  <ul>
  <li>Red Hat Enterprise Linux Server release 6.2 (Santiago)</li>
  <li>PHP Version 5.3.3</li>
  <li>Apache/2.2.15 in Prefork</li>
  <li>Memcache server 1.4.14</li>
  <li>libmemcached 1.0.9</li>
  <li>PHP memcached plugin 2.0.1</li>
  </ul>