Opens a connection to memcached server.

@param \stdClass $initData
482317
private function openConnection(\stdClass $initData)
    {
        $connectionOptions = $this->parseConnectionData($initData);
        if (isset($this->persistent) && (boolean) $this->persistent) {
            $this->persistentConnect($connectionOptions);
        } else {
            $this->notPersistentConnect($connectionOptions);
        }
    }
1368199
protected function logInitialization(array $logData)
    {
        if (!$this->site->getSolrConfiguration()->getLoggingIndexingIndexQueueInitialization()) {
            return;
        }

        $logSeverity = isset($logData['error']) ? SolrLogManager::ERROR : SolrLogManager::NOTICE;
        $logData = array_merge($logData, [
            'site' => $this->site->getLabel(),
            'indexing configuration name' => $this->indexingConfigurationName,
            'type' => $this->type,
        ]);

        $message = 'Index Queue initialized for indexing configuration ' . $this->indexingConfigurationName;
        $this->logger->log($logSeverity, $message, $logData);
    }
396412
public function _setInit($key = null, $val = null)
    {
        if (is_null($key)) {
            $this->_init = array();
        } elseif (is_null($val)) {
            unset($this->_init[$key]);
        } else {
            switch ($key) {
            case 'capability':
                if ($ci = $this->getParam('capability_ignore')) {
                    $ignored = array();

                    foreach ($ci as $val2) {
                        $c = explode('=', $val2);

                        if ($val->query($c[0], isset($c[1]) ? $c[1] : null)) {
                            $ignored[] = $val2;
                            $val->remove($c[0], isset($c[1]) ? $c[1] : null);
                        }
                    }

                    if ($this->_debug->debug && !empty($ignored)) {
                        $this->_debug->info(sprintf(
                            'CONFIG: IGNORING these IMAP capabilities: %s',
                            implode(', ', $ignored)
                        ));
                    }
                }

                $val->attach($this);
                break;
            }

            /* Nothing has changed. */
            if (isset($this->_init[$key]) && ($this->_init[$key] === $val)) {
                return;
            }

            $this->_init[$key] = $val;
        }

        $this->changed = true;
    }
491681
public function init()
    {
        $this->db = \PHPDaemon\Clients\Mongo\Pool::getInstance($this->config->mongoclientname->value);
        $this->cache = \PHPDaemon\Clients\Memcache\Pool::getInstance($this->config->memcacheclientname->value);
        if (!isset($this->config->limitinstances)) {
            $this->log('missing \'limitInstances\' directive');
        }
    }
354606
public static function execute(&$syncdata)
	{
		self::init();
		try {
			$action = $syncdata->get('action');
			$completed = $syncdata->get('completed');
			if (empty($completed)) {
				$master = $syncdata->get('master');
				$syncid = $syncdata->get('syncid');
				$userbatch = $syncdata->get('userbatch', 500);

				//setup some variables
				$MasterPlugin = Factory::getAdmin($master);
				$MasterUser = Factory::getUser($master);

				$db = Factory::getDBO();
				if (!static::getStatus($syncid)) {
					//tell JFusion a sync is in progress
					static::changeStatus($syncid, 1);
					$user_count = 1;
					//going to die every x users so that apache doesn't time out
					//we should start with the import of slave users into the master

					/**
					 * should be reset at end.
					 */
					$slave_data = $syncdata->get('slave_data', array());
					$plugin_offset = $syncdata->get('plugin_offset', 0);
					if (!empty($slave_data)) {
						for ($i = $plugin_offset; $i < count($slave_data); $i++) {
							$syncdata->set('plugin_offset', $i);

							$user_offset = $syncdata->get('user_offset', 0);
							//get a list of users
							$jname = $slave_data[$i]->jname;
							if ($jname) {
								$SlavePlugin = Factory::getAdmin($jname);
								$SlaveUser = Factory::getUser($jname);
								if ($action == 'master') {
									$userlist = $SlavePlugin->getUserList($user_offset, $userbatch);
									$action_name = $jname;
									$action_reverse_name = $master;
								} else {
									$userlist = $MasterPlugin->getUserList($user_offset, $userbatch);
									$action_name = $master;
									$action_reverse_name = $jname;
								}

								//catch to determine if the plugin supports limiting users for sync performance
								if (count($userlist) != $slave_data[$i]->total_to_sync) {
									//the userlist has already been limited so just start with the first one from the retrieved results
									$user_offset = 0;
								}
								//perform the actual sync
								for ($j = $user_offset; $j < count($userlist); $j++) {
									$syncdata->set('user_offset', $syncdata->get('user_offset', 0) + 1);

									$status = array();
									$userinfo = new Userinfo(null);
									$userinfo->bind($userlist[$j]);

									$UpdateUserInfo = null;
									try {
										if ($action == 'master') {
											$userinfo = $SlaveUser->getUser($userinfo);
											if ($userinfo instanceof Userinfo) {
												$MasterUser->resetDebugger();
												if ($MasterUser->validateUser($userinfo)) {
													$UpdateUserInfo = $MasterUser->updateUser($userinfo);

													$status = $MasterUser->debugger->get();

													if (!$UpdateUserInfo instanceof Userinfo) {
														//make sure the userinfo is available
														$UpdateUserInfo = $MasterUser->getUser($userinfo);
													}
												}
											}
										} else {
											$userinfo = $MasterUser->getUser($userinfo);
											if ($userinfo instanceof Userinfo) {
												$SlaveUser->resetDebugger();
												if ($MasterUser->validateUser($userinfo)) {
													$UpdateUserInfo = $SlaveUser->updateUser($userinfo);

													$status = $SlaveUser->debugger->get();

													if (!$UpdateUserInfo instanceof Userinfo) {
														//make sure the userinfo is available
														$UpdateUserInfo = $SlaveUser->getUser($userinfo);
													}
												}
											}
										}
									} catch (Exception $e) {
										$status[LogLevel::ERROR] = $e->getMessage();
										$UpdateUserInfo = null;
									}

									$sync_log = new stdClass;
									$sync_log->syncid = $syncid;
									$sync_log->jname = $jname;
									$sync_log->message = '';
									$sync_log->data = '';

									$sync_log->username = $userlist[$j]->username;
									$sync_log->email = $userlist[$j]->email;

									if (!isset($status['action'])) {
										$status['action'] = 'error';
									}
									if (!$userinfo instanceof Userinfo || !$UpdateUserInfo instanceof Userinfo || !empty($status[LogLevel::ERROR])) {
										$status['action'] = 'error';
										$sync_log->message = (is_array($status[LogLevel::ERROR])) ? implode('; ', $status[LogLevel::ERROR]) : $status[LogLevel::ERROR];
										$error = new stdClass();
										$error->conflict = new stdClass();
										$error->conflict->userinfo = $UpdateUserInfo;
										$error->conflict->error = $status[LogLevel::ERROR];
										$error->conflict->debug = (!empty($status[LogLevel::DEBUG])) ? $status[LogLevel::DEBUG] : '';
										$error->conflict->jname = $action_reverse_name;
										$error->user = new stdClass();
										$error->user->jname = $action_name;
										$error->user->userinfo = $userinfo;
										$error->user->userlist = $userlist[$j];

										$sync_log->type = 'ERROR';
										if (!empty($error->conflict->userinfo->username) && ($error->user->userinfo->username != $error->conflict->userinfo->username)) {
											$sync_log->type = 'USERNAME';
										} else if (!empty($error->conflict->userinfo->email) && $error->user->userinfo->email != $error->conflict->userinfo->email) {
											$sync_log->type = 'EMAIL';
										}

										$sync_log->data = json_encode($error);
										$syncdata->set('sync_errors', $syncdata->get('sync_errors', 0) + 1);
									} else {
										//usersync loggin enabled
										$sync_log->username = isset($UpdateUserInfo->username) ? $UpdateUserInfo->username : $userinfo->username;
										$sync_log->email = isset($UpdateUserInfo->email) ? $UpdateUserInfo->email : $userinfo->email;
										if ($UpdateUserInfo instanceof Userinfo) {
											//update the lookup table
											if ($action == 'master') {
												$MasterUser->updateLookup($UpdateUserInfo, $userinfo);
											} else {
												$SlaveUser->updateLookup($userinfo, $UpdateUserInfo);
											}
										}
									}
									$sync_log->action = $status['action'];

									//append the error to the log
									$db->insertObject('#__jfusion_sync_details', $sync_log);

									//update the counters
									$slave_data[$i]->{$status['action']} += 1;
									$slave_data[$i]->total -= 1;

									$syncdata->set('slave_data', $slave_data);

									$syncdata->set('synced_users', $syncdata->get('synced_users', 0) + 1);
									//update the database, only store syncdata every 20 users for better performance
									if ($user_count >= 20) {
										if ($slave_data[$i]->total == 0) {
											//will force the next plugin and first user of that plugin on resume
											$syncdata->set('plugin_offset', $syncdata->get('plugin_offset', 0) + 1);
											$syncdata->set('user_offset', 0);
										}
										static::updateData($syncdata);
										//update counters
										$user_count = 1;
									} else {
										//update counters
										$user_count++;
									}
									$userbatch--;

									if ($syncdata->get('synced_users', 0) == $syncdata->get('total_to_sync', 0)) {
										break;
									} elseif ($userbatch == 0 || $slave_data[$i]->total == 0) {
										//exit the process to prevent an apache timeout; it will resume on the next ajax call
										//save the syncdata before exiting
										if ($slave_data[$i]->total == 0) {
											//will force  the next plugin and first user of that plugin on resume
											$syncdata->set('plugin_offset', $syncdata->get('plugin_offset', 0) + 1);
											$syncdata->set('user_offset', 0);
										}
										static::updateData($syncdata);
										//tell Joomla the batch has completed
										static::changeStatus($syncid, 0);
										return;
									}
								}
							}
						}
					}

					$syncdata->set('slave_data', $slave_data);
					if ($syncdata->get('synced_users', 0) == $syncdata->get('total_to_sync', 0)) {
						//end of sync, save the final data

						$syncdata->set('completed', true);
						static::updateData($syncdata);

						//update the finish time
						$db = Factory::getDBO();

						$query = $db->getQuery(true)
							->update('#__jfusion_sync')
							->set('time_end = ' . $db->quote(time()))
							->where('syncid = ' . $db->quote($syncid));

						$db->setQuery($query);
						$db->execute();
					}
					static::updateData($syncdata);
					static::changeStatus($syncid, 0);
				}
			}
		} catch (Exception $e) {
			Framework::raise(LogLevel::ERROR, $e);
		}
	}
974100
public static function getInstance($type, $init)
    {

        if (!self::$cachingInstance) {
            self::$cachingInstance = new IDS_Caching_Database($type, $init);
        }
        return self::$cachingInstance;
    }
1249605
public function initialize() : void
  {
    $connection = config('database.default');

    Accessor::$appRoot       = config('app.dir');
    UpstartConfig::$database = config("database.connections.{$connection}");

    if (!DB::start()) {
      $this->exception('Could not establish a database connection.');
    }

    $this->loadView();
  }
901095
final public function initialize()
    {
        $this->_ensureModuleExistence();
        $this->memcache = new Memcache();
        // support multiple hosts using semicolon to separate hosts
        $hosts = explode(";", $this->host);
        // different ports for each hosts the same way
        $ports = explode(";", $this->port);
        if (count($hosts) > 1) {
            if (count($ports) < 1) {
                $ports = array_fill(0, count($hosts), self::DEFAULT_PORT);
            } elseif (count($ports) == 1) {
                // if we have just one port, use it for all hosts
                $_p = $ports[0];
                $ports = array_fill(0, count($hosts), $_p);
            }
            foreach ($hosts as $i => $host) {
                $this->memcache->addServer($host, $ports[$i]);
            }
        } else {
            // just connect to the single host
            $this->memcache->connect($hosts[0], $ports[0]);
        }
    }
602342
public function init() {
        if (VERBOSE) echo 'INIT:' ,PHP_EOL;
        if (VERBOSE) echo ' CONNECTING API' ,PHP_EOL;
        $this->api->auth();
        if (VERBOSE) echo ' API CONNECTED' ,PHP_EOL;
        if (VERBOSE) echo ' CONNECTING SQL' ,PHP_EOL;
        $this->db->connect();
        if (VERBOSE) echo ' SQL CONNECTED' ,PHP_EOL;
        if (VERBOSE) echo ' CHECKING PATHS' ,PHP_EOL;
        if (DEBUG) echo '  CHECKING TMP DIR AT : '.$this->tmp_dir ,PHP_EOL;
        if (!file_exists($this->tmp_dir)) {
            throw new Exception("Path for 'tmp_dir' not found at '".$this->tmp_dir."'!");
        }
        if (DEBUG) echo '  CHECKING DUMP DIR AT : '.$this->dumps_dir ,PHP_EOL;
        if (!file_exists($this->dumps_dir)) {
            throw new Exception("Path for 'dumps_dir' not found at '".$this->dumps_dir."'!");
        }
        if (VERBOSE) echo ' PATHS FOUND' ,PHP_EOL;
    }
686026
public function init(\stdClass $initData = null)
    {
        try {
            if ($initData === null) {
                $this->connection->connect(self::DEFAULT_HOST);
            } else {
                $this->openConnection($initData);
            }
        } catch (\RedisException $e) {
            throw new RedisConnectionException("Redis driver exception was thrown.", $e);
        }
    }
400640
protected function setCachedData()
    {
        if (empty($this->iElementID)) {
            return;
        }

        $arCacheTags = static::getCacheTag();
        $sCacheKey = $this->iElementID;

        $this->arModelData = CCache::get($arCacheTags, $sCacheKey);
        if (!$this->isEmpty()) {
            return;
        }

        $this->setData();

        //Set cache data
        CCache::forever($arCacheTags, $sCacheKey, $this->arModelData);
    }
484225
public static function getInstance($type, $init)
    {
        if (!self::$cachingInstance) {
            self::$cachingInstance = new FileCache($type, $init);
        }

        return self::$cachingInstance;
    }
1216108
public function init(\stdClass $initData = null)
    {
        if ($initData === null) {
            $this->connection->connect();
        } else {
            $this->openConnection($initData);
        }
    }
1020671
private static function init() {
		static::$manager = new MountManager(self::$filesystems);
		$local           = new CachedAdapter(new Local("/", LOCK_EX, Local::SKIP_LINKS), new CacheStore());
		self::addAdapter("local", $local);
		self::addAdapter("file", $local);
		self::$manager->addPlugin(new ListPaths());
	}
1096991
protected function initData()
    {
        parent::initData();
        array_walk($this->_data, function (&$indexConfigData, $indexName) {
            $indexConfigData = $this->initIndexConfig($indexName, $indexConfigData);
        });
    }
344802
public function init()
	{
		// generic driver initialisation
		parent::init();

		if ($this->memcached === false)
		{
			// do we have the PHP memcached extension available
			if ( ! class_exists('Memcached') )
			{
				throw new \FuelException('Memcached sessions are configured, but your PHP installation doesn\'t have the Memcached extension loaded.');
			}

			// instantiate the memcached object
			$this->memcached = new \Memcached();

			// add the configured servers
			$this->memcached->addServers($this->config['servers']);

			// check if we can connect to the server(s)
			if ($this->memcached->getVersion() === false)
			{
				throw new \FuelException('Memcached sessions are configured, but there is no connection possible. Check your configuration.');
			}
		}
	}
438274
function initializeClassAttribute( $classAttribute )
    {
        if ( $classAttribute->attribute( self::DEFAULT_FIELD ) == null )
            $classAttribute->setAttribute( self::DEFAULT_FIELD, 0 );
        $classAttribute->store();
    }