Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(PHP)choose memcache::connect or memcache::pconnect?

Tags:

php

memcached

I'm using php::memcache module to connect a local memcached server (@127.0.0.1), but I don't know that which one I should use, memcache::connect() or memcache::pconnect ? Does memcache::pconnect will consume many resource of the server?

Thank you very much for your answer!

like image 439
cyberscorpio Avatar asked Dec 30 '22 03:12

cyberscorpio


1 Answers

Memcached uses a TCP connection (handshake is 3 extra packets, closing is usually 4 packets) and doesn't require any authentication. Therefore, the only upside to using a persistent connection is that you don't need to send those extra 7 packets and don't have to worry about having a leftover TIME-WAIT port for a few seconds.

Sadly, the downside of sacrificing those resources is far greater than the minor upsides. So I recommend not using persistent connections in memcached.

like image 160
St. John Johnson Avatar answered Jan 12 '23 15:01

St. John Johnson