All pastes #965930 Raw Edit

Stuff

public php v1 · immutable
·published 2008-04-01 10:42 UTC
rendered paste body
  /**   * Function to connect to the memCache server   *   * If failure to connecting to server, it will try next sever in the array.   *   * @param int|string[optional] $server Index of stored servers or costom server   * @param bool[optional] $pCon Pressistent connection   */  function memConnect($server = null, $pCon = null) {    // Check if memCache was generated    if($this->memCache) {      // Check if a server was specified      if($server) {        // Check if passed value is a costom IP or server array key        if(strpos($server, '.') === false) {          $server = array($this->serverArray[$server], $this->portArray[$server]);        } else {          // Split server IP from Port          $server = split(':', $server);          // If Port not specified store default          if(!array_key_exists(1, $server)) $server[1] = '11211';        }        // Check if pressistent connection was requested        // Determin which memCache function to use for connection        $pCon = ($pCon ? 'pconnect' : 'connect');        $memcon = @$this->memCache->$pCon($server[0], $server[1]);        if($memcon) {          return array(1, 1);        } else {          $this->p_error(0, 'There was an error while trying to connect to the memcache server IP: ' . $server[0] . ' Port: ' . $server[1]);          return array(0, 'Error with connection to memcache server');        }      } else {      // ok grab one from the serverArray      }    } else {     // memcache object was not created in the constructor    }  }