单key指令

@param string $method Redis指令
@param string $key Redis Key
@param array $arguments Redis指令参数
@return mixed
328404
private function single(string $method, string $key, array $arguments)
    {
        $redisPoolName = $this->lookup($this->generateUniqueKey($key));

        if (!isset(RedisProxyFactory::$redisCoroutines[$redisPoolName])) {
            if (getInstance()->getAsynPool($redisPoolName) == null) {
                return false;
            }
            RedisProxyFactory::$redisCoroutines[$redisPoolName] = getInstance()->getAsynPool($redisPoolName)->getCoroutine();
        }
        $redisPoolCoroutine = RedisProxyFactory::$redisCoroutines[$redisPoolName];

        if ($method === 'cache') {
            $result = $redisPoolCoroutine->$method(...$arguments);
        } else {
            $result = $redisPoolCoroutine->__call($method, $arguments);
        }

        return $result;
    }
472697
private function callFindOrFailBy(string $method, array $arguments)
    {
        $whereByWithUpper = lcfirst(substr($method, 12, mb_strlen($method)));
        $whereBy = Str::convertCamelCaseToSnakeCase($whereByWithUpper);

        return $this->where($whereBy, '=', $arguments[0])->findOrFail();
    }
1236026
public function call(string $method, array $arguments): ResponseInterface
    {
        try {
            return $this->__soapCall($method, $arguments, null, $this->getHeader());
        } catch (\Exception $e) {
            $exception = new ClientException($e->getMessage(), $e->getCode(), $e);

            if ($this->debug) {
                $exception->request = ClientException::formatXml($this->__getLastRequest());
                $exception->response = ClientException::formatXml($this->__getLastResponse());
            }

            throw $exception;
        }
    }
1017528
public function evalMock(array $arguments)
    {
        $args         = $arguments[2];
        $numKeys      = $arguments[3];
        $keys         = array_slice($args, 0, $numKeys);
        $evalMockArgs = array_slice($args, $numKeys);
        $arrRedis     = $index2Key = [];

        if (empty($keys)) {
            //如果没有设置缓存key，则连接所有的实例
            $arrRedis = $this->getAllTargets();
        } else {
            //根据脚本中用到的key计算出需要连接哪些实例
            foreach ($keys as $key) {
                $key = $this->generateUniqueKey($key);
                $redisPoolName = $this->lookup($key);

                $index = array_search($redisPoolName, $arrRedis, true);
                if ($index === false) {
                    $index = count($arrRedis);
                    $arrRedis[] = $redisPoolName;
                }
                $index2Key[$index][] = $key;
            }
        }

        $ret = [];
        foreach ($arrRedis as $index => $redisPoolName) {
            if (!isset(RedisProxyFactory::$redisCoroutines[$redisPoolName])) {
                if (getInstance()->getAsynPool($redisPoolName) == null) {
                    return [];
                }
                RedisProxyFactory::$redisCoroutines[$redisPoolName] = getInstance()->getAsynPool($redisPoolName)->getCoroutine();
            }
            $redisPoolCoroutine = RedisProxyFactory::$redisCoroutines[$redisPoolName];

            $arrKeys = empty($index2Key) ? $index2Key : $index2Key[$index];
            $res     = $redisPoolCoroutine->evalMock($arguments[0], $arguments[1], array_merge($arrKeys, $evalMockArgs), count($arrKeys));

            if ($res instanceof \Generator) {
                $ret[] = $res;
            }
        }

        foreach ($ret as $k => $item) {
            $ret[$k] = yield $item;
        }

        return $ret;
    }
459741
protected function __parseLinkJoin($arguments, $method)
	{
		if(!isset($this->operationOption['join']))
		{
			$this->operationOption['join'] = array();
		}
		array_unshift($arguments,$method);
		$this->operationOption['join'][] = $arguments;
	}
951335
private static function _getValueByKeyWithDefault($key,array $args, $default = null) {
        //使用方法
        list($temp, $def) = Str::explode($key, ' ', 2, $default);
        $temps  = explode(':', $temp, 2);
        $oldKey = $temps[0];
        $newKey = end( $temps );
        return array(
            $newKey,
            array_key_exists($oldKey, $args) ? $args[$oldKey] : $def,
            $oldKey
        );
    }
382902
public function setUp($key, $arguments = [])
    {
        // Set cache arguments.
        $this->setArguments($arguments);

        // Start output buffer.
        ob_start();

        // Store cache key.
        $this->keys[] = $key = (string) $key;

        // Return cache status.
        return $this->cached = $this->cache->has($key);
    }
1034035
protected function fetchDefaultCacheRecord($method, $args)
    {
        // Instead of using has() we directly implement the value getter
        // to avoid additional cache hits if the key exists.
        if (is_null($value = parent::get($args['key']))) {
            $this->checkReservedKeyPattern($args['key']);

            call_user_func_array([$this, 'storeKeywords'], array_only($args, ['key', 'minutes', 'keywords']));

            $this->setKeywordsOperation(true);

            $value = call_user_func_array(['parent', $method], array_values($args));

            $this->setKeywordsOperation(false);
        }

        if (! $this->operatingOnKeywords()) {
            $this->resetCurrentKeywords();
        }

        return $value;
    }
1253033
public function query($id, $method, array $arguments)
    {
        $message = array(
            'jsonrpc' => self::VERSION,
            'id' => $id,
            'method' => $method
        );

        if ($arguments !== null) {
            $message['params'] = $arguments;
        }

        $this->messages[] = $message;
        return $this;
    }
110117
public function call(string $method, array $arguments): Response
    {
        try {
            return $this->request('GET', $method, [
                'query' => $arguments
            ]);
        } catch (\Exception $e) {
            throw new ClientException($e->getMessage(), $e->getCode(), $e);
        }
    }
518281
protected function get($method, array $data = [], $key = 'key')
    {
        $data = $this->data($data);

        if (!isset($this->cache[$method][$key])) {
            $this->cache[$method][$key] = $this->client->$method($data);
        }

        return $this->cache[$method][$key];
    }
739920
public function getCacheKey($method, $args = null, $tag)
    {
        // Sort through arguments
        foreach($args as &$a) {
            if ($a instanceof Model) {
                $a = get_class($a).'|'.$a->getKey();
            }
        }

        // Create hash from arguments and query
        $args = serialize($args) . serialize($this->getScopeQuery());

        return sprintf('%s-%s@%s-%s',
            config('app.locale'),
            $tag,
            $method,
            md5($args)
        );
    }
1215313
public function notify($method, array $arguments)
    {
        $message = array(
            'jsonrpc' => self::VERSION,
            'method' => $method
        );

        if ($arguments !== null) {
            $message['params'] = $arguments;
        }

        $this->messages[] = $message;
        return $this;
    }
315835
public function do_get($key)
    {
        $redis = is_object($this->_redis) ? $this->_redis : $this->_getRedis();
        return $redis->get($this->_prefix . $key);
    }
300612
private function callFindBy(string $method, array $arguments)
    {
        $whereByWithUpper = lcfirst(substr($method, 6, mb_strlen($method)));
        $whereBy = Str::convertCamelCaseToSnakeCase($whereByWithUpper);

        return $this->where($whereBy, '=', $arguments[0])->find();
    }
1048516
public static function request($method, $arguments = array())
    	{
    		// load api key
    		$apiKey = Bootstrap::$bag['config']->getMailer()->getPassword();

    		// determine endpoint
    		$endPoint = 'https://mandrillapp.com/api/1.0/' . $method . '.json';

    		// build payload
    		$arguments['key'] = $apiKey;

    		// setup curl request
    		$ch = curl_init();
    		curl_setopt($ch, CURLOPT_URL, $endPoint);
    		curl_setopt($ch, CURLOPT_TIMEOUT, 30);
    		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
    		curl_setopt($ch, CURLOPT_POST, true);
    		curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
    		curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($arguments));
    		$response = curl_exec($ch);

    		// catch errors
    		if (curl_errno($ch)) {
    			#$errors = curl_error($ch);
    			curl_close($ch);

    			// return false
    			return false;
    		} else {
    			curl_close($ch);

    			// return array
    			return json_decode($response, true);
    		}
    	}
373466
protected function handleRelationField($method, $arguments)
    {
        if (!method_exists($this->model, $method)) {
            return false;
        }

        if (!($relation = $this->model->$method()) instanceof EloquentRelation) {
            return false;
        }

        if ($relation    instanceof HasOne
            || $relation instanceof BelongsTo
            || $relation instanceof MorphOne
        ) {
            $this->model->with($method);

            if (count($arguments) == 1 && $arguments[0] instanceof \Closure) {
                return $this->addRelation($method, $arguments[0]);
            }

            if (count($arguments) == 2 && $arguments[1] instanceof \Closure) {
                return $this->addRelation($method, $arguments[1], $arguments[0]);
            }

            return $this->addField($method, Arr::get($arguments, 0))->setRelation(Str::snake($method));
        }

        if ($relation    instanceof HasMany
            || $relation instanceof MorphMany
            || $relation instanceof BelongsToMany
            || $relation instanceof HasManyThrough
        ) {
            if (empty($arguments) || (count($arguments) == 1 && is_string($arguments[0]))) {
                return $this->showRelationAsField($method, $arguments[0] ?? '');
            }

            $this->model->with($method);

            if (count($arguments) == 1 && is_callable($arguments[0])) {
                return $this->addRelation($method, $arguments[0]);
            } elseif (count($arguments) == 2 && is_callable($arguments[1])) {
                return $this->addRelation($method, $arguments[1], $arguments[0]);
            }

            throw new \InvalidArgumentException('Invalid eloquent relation');
        }

        return false;
    }