• PHP Video Tutorials

PHP - Memcache::pconnect() Function



Memcache::pconnect() function can open a memcached server persistent connection.

Syntax

mixed Memcache::pconnect( string $host [, int $port [, int $timeout ]] )

Memcache::pconnect() function is identical to Memcache::connect() function with difference is that the connection it establishes is persistent. This connection is not closed after an end of script execution and by Memcache::close() function. We can also use memcache_pconnect() function.

Memcache::pconnect() function can return a Memcache object or false on failure.

Example

<?php
   /* Procedural API */
   $memcache_obj = memcache_pconnect("memcache_host", 11211);

   /* OO API */
   $memcache_obj = new Memcache;
   $memcache_obj->pconnect("memcache_host", 11211);
?>
Advertisements