Server IP : 127.0.0.2 / Your IP : 3.144.112.72 Web Server : Apache/2.4.18 (Ubuntu) System : User : www-data ( ) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/vendor/laravel/framework/src/Illuminate/Cache/ |
Upload File : |
<?php namespace Illuminate\Cache; use Memcached; use RuntimeException; class MemcachedConnector { /** * Create a new Memcached connection. * * @param array $servers * @param string|null $connectionId * @param array $options * @param array $credentials * @return \Memcached * * @throws \RuntimeException */ public function connect( array $servers, $connectionId = null, array $options = [], array $credentials = [] ) { $memcached = $this->getMemcached( $connectionId, $credentials, $options ); if (! $memcached->getServerList()) { // For each server in the array, we'll just extract the configuration and add // the server to the Memcached connection. Once we have added all of these // servers we'll verify the connection is successful and return it back. foreach ($servers as $server) { $memcached->addServer( $server['host'], $server['port'], $server['weight'] ); } } return $this->validateConnection($memcached); } /** * Get a new Memcached instance. * * @param string|null $connectionId * @param array $credentials * @param array $options * @return \Memcached */ protected function getMemcached($connectionId, array $credentials, array $options) { $memcached = $this->createMemcachedInstance($connectionId); if (count($credentials) == 2) { $this->setCredentials($memcached, $credentials); } if (count($options)) { $memcached->setOptions($options); } return $memcached; } /** * Create the Memcached instance. * * @param string|null $connectionId * @return \Memcached */ protected function createMemcachedInstance($connectionId) { return empty($connectionId) ? new Memcached : new Memcached($connectionId); } /** * Set the SASL credentials on the Memcached connection. * * @param \Memcached $memcached * @param array $credentials * @return void */ protected function setCredentials($memcached, $credentials) { list($username, $password) = $credentials; $memcached->setOption(Memcached::OPT_BINARY_PROTOCOL, true); $memcached->setSaslAuthData($username, $password); } /** * Validate the given Memcached connection. * * @param \Memcached $memcached * @return \Memcached */ protected function validateConnection($memcached) { $status = $memcached->getVersion(); if (! is_array($status)) { throw new RuntimeException('No Memcached servers added.'); } if (in_array('255.255.255', $status) && count(array_unique($status)) === 1) { throw new RuntimeException('Could not establish Memcached connection.'); } return $memcached; } }