Esempio n. 1
0
 /**
  * Establish connection with memcache
  * @param array $user_pool Associated array of memcache addresses to port numbers
  * @param string $user_prefix Prefix to prepend to all memcache key names utilized by this instance of Memcache
  * @return null.
  * @since v1.1 CHANGED: return values to false/mixed
  */
 static function connect($user_pool = false, $user_prefix = false)
 {
     self::$memcache = new Memcache();
     // PHP Extension Lib
     // The Config class not existing should throw fatal for us making the coder go to this line.
     // Coder, if you are reading this, pass your array of memcache servers when using cacheMemcache::connect() :)
     $servers = is_array($user_pool) ? $user_pool : null;
     // removing config refs
     foreach ((array) $servers as $memcache_server) {
         $connect_result = self::$memcache->addserver(key($memcache_server), $memcache_server[key($memcache_server)], self::persistent, 1, self::retry_interval, True);
         if (!$connect_result) {
             trigger_error(sprintf('memcache::addserver() failed (%s:%s)', key($memcache_server), $memcache_server[key($memcache_server)]), E_USER_ERROR);
             return false;
         }
     }
     if (is_string($user_prefix) || is_numeric($user_prefix)) {
         self::$prefix = $user_prefix;
     }
     return $connect_result;
 }