• PHP Video Tutorials

PHP - Memcache::connect() Function



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

Syntax

bool Memcache::connect( string $host [, int $port [, int $timeout ]] )

Memcache::connect() function can establish a connection to Memcached server. The connection that was opened using Memcache::connect() function can be automatically closed at an end of script execution. Also, we can close it with the Memcache::close() function. Also, we can use the memcache_connect() function.

Memcache::connect() function can return true on success or false on failure.

Example

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

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