I'm pretty sure this is a CakePHP bug, but figured someone here may have run across this and know how to fix. FYI - I've created a ticket.
I run PHP as fastcgi under 开发者_开发知识库nginx via php5-fpm. When I use 'Memcache' as the engine for my cake cache, I notice that TCP connections are not closed. I notice that cake's MemcacheEngine does not ever call PHP memcache::close().
For people who run PHP under non-fastcgi processes, I think this is OK as at the end of the PHP request the process ends, and "breaks" the TCP connection between PHP and memcached.
Using php5-fpm this is not the case, as the PHP process stays running to be re-used.
Does anyone know a best practice for this? I'm thinking of modifying the CakePHP code to close the connection at the end of processing - but I'm wondering if there is a better way.
Note: CakePHP's MemcacheEngine does NOT use pconnect.
My version info:
Ubuntu 10.10 64bit
PHP 5.3.3
PECL memcache 3.0.5
memcached 1.4.5
cakephp 1.3.8
Turns out MemcacheEngine uses Memcache::addServer() which by default uses persistence. It is correctly re-using the connections between my FPM children and my memcached pool.
Cake has added a 'persistent' option now, to allow the overriding of the default behavior for those that wish: http://cakephp.lighthouseapp.com/projects/42648/tickets/1705-cake-138-memcacheengine-does-not-close-connection
精彩评论