On Fri, Feb 12, 2010 at 01:26, Brian Moon <br...@moonspot.net> wrote:
> Slightly related: Is there any way to get persistent connections for >> memcached in PHP? There's no real static variables in it, but there >> seems to be something for mysql that attaches connections to the parent >> apache process, is there something similar for memcached? Or are you >> just permanently screwed and have to re-initialize everything each >> pageview? I tried googling for it, but I only get... unhelpful... results. >> > > http://us2.php.net/manual/en/memcached.construct.php > > or > > http://us3.php.net/manual/en/function.memcache-addserver.php > > depending on your library. > Thanks, but how does that work exactly? I've been trying to find information about it, and what I've pieced together so far is that if you are running PHP as an Apache module, and if you are making your own extension in C, then you get access to methods that allow you to store stuff in some sort of shared memory in the Apache process, that you can retrieve between pageviews, such as socket handles or initialized arrays or similar. But there's nothing in the PHP language itself to do something like that, you have to make your own C module. Correct? And that then, in turn, means that the answer to the original question is that adding more servers doesn't slow down the app, if they're using persistent connections, because client initialization will only happen once? (Given the prerequsities above, and given that they actually make sure they only init once like a comment on that memcached manual page describes) And is this true for both PHP clients? /Henrik