初始化准备工作.

@param $configKey
353729
protected function prepare($configKey)
    {
        $config = getInstance()->config->get($configKey, []);
        $this->beanstalkConfig = $config = array_replace($this->getDefaultBeanstalkConf(), $config);
        $this->client = new Pheanstalk($config['host'], $config['port'], $config['connectTimeout'], $config['connectPersistent']);
        $this->useTube($config['tube']);
    }
301338
public function work($queueKey)
    {
        // 重启队列
//        Helper::queueReload();
        $this->queueKey     = $queueKey;
        $rabbitMqConfig     = RabbitMqConfig::getCommon('rabbit_mq');
        $this->exchangeName = $rabbitMqConfig['exchange_name'];
        $this->exchangeType = AMQP_EX_TYPE_TOPIC;
        $this->queueConfig  = RabbitMqConfig::getQueue($queueKey);
        $this->version      = Helper::getVersion();

        $this->rabbtMq      = new RabbitMq($this->exchangeName, $this->exchangeType);
        $this->queue        = new \AMQPQueue($this->rabbtMq->getChannel());
        $this->queue->setName($queueKey);// 设置队列名
        $this->queue->setFlags(AMQP_DURABLE);// 设置队列持久化
        $this->queue->declareQueue();// 队列存在创建,否者就不创建
        $this->queue->bind($this->exchangeName, $this->queueConfig['route_key']);// 绑定route_key

        $consoleQueueConfig = RabbitMqConfig::getQueue('rabbit_queue_console');
        $this->queue->bind($this->exchangeName, $consoleQueueConfig['route_key']);// 绑定route_key

        $this->queue->consume([$this, 'receive']);

        $this->rabbtMq->disconnection();
    }
1112491
protected function _load($key)
    {
        $parts = explode('.', $key);
        $first = array_shift($parts);
        if (isset($this->_loaded[$first])) {
            return;
        }
        $cookie = $this->getController()->getRequest()->getCookie($first);
        if ($cookie === null) {
            return;
        }
        $config = $this->configKey($first);
        $this->_loaded[$first] = true;
        $this->_values[$first] = $this->_decrypt($cookie, $config['encryption'], $config['key']);
    }
750834
private function loadFile(
        array &$items,
        string $path,
        string $pathRelative,
        string $configKey,
        $environment = null
    ): void {
        // Build filename.
        $filename = $path;
        if ($pathRelative !== null && $pathRelative !== '') {
            $filename .= '/' . $pathRelative;
        }
        $filename .= '/' . $configKey;
        if ($environment !== null) {
            $filename .= '.' . (string)$environment;
        }
        $filename .= '.php';

        // Load configuration.
        if (!file_exists($filename)) {
            return;
        }
        $config = require($filename);

        // Parse config.
        $itemsData = &$items;
        if ($pathRelative !== '') {
            $pathSegments = explode('.', $pathRelative);
            foreach ($pathSegments as $pathSegment) {
                $itemsData = &$itemsData[$pathSegment];
            }
        }
        if (!isset($itemsData[$configKey])) {
            $itemsData[$configKey] = null;
        }
        if (is_array($itemsData[$configKey]) && is_array($config)) {
            $itemsData[$configKey] = array_merge($itemsData[$configKey], $config);
        } else {
            $itemsData[$configKey] = $config;
        }
    }
1240596
public function delete(string $section, string $key) : bool
    {
        return $this->config->delete($this->concat($section, $key));
    }
1152341
public function forget($key)
    {

        // remove item from DB
        $this->dbProvider->forget($key);

        // remove item from original config
        $this->origConfig->offsetUnset($key);

    }
728807
protected function loadConfigFile(string $key)
    {
        $key = strtolower($key);
        $filename = $this->path . DIRECTORY_SEPARATOR . ucfirst($key) . Config::CONFIG_FILE_EXTENSION;

        if (file_exists($filename)) {
            $this->configuration[$key] = require $filename;
            return;
        }

        throw new ConfigException('Unable to load resource: ' . $filename);
    }
1296308
protected static function _getConfigByKey($key) {
		$dbConfig = self::_getEngine()->get($key);
		$fileConfig = Configure::read($key);
		if (!is_null($fileConfig)) {
			$dbConfig = Hash::mergeDiff((array)$dbConfig, $fileConfig);
		}

		return $dbConfig;
	}
165401
public static function set($key,$data,$period,$config)
    {
        static::initRedis();
        /**
         * 确定key
         */
        static::$key = $key;
        if(is_array($key) && count($key) == 2){
            static::$group = $key[0];
            static::$key = $key[1];
        }
        static::$md5key =  md5(static::$key );
        /**
         * 判断是删除缓存还是设置缓存
         */
        if($data == null){
            /**
             * 删除缓存
             */
            $returnData = static::$Redis->del('cache_'.static::$typeCache.'_'.static::$group.'_'.static::$md5key);
        }else{
            /**
             * 设置缓存  准备数据
             */
            static::$data = serialize($data);
            /**
             * $typeCache  缓存类型  拼接  分组   =  表名称
             */
            $returnData = static::$Redis->set('cache_'.static::$typeCache.'_'.static::$group.'_'.static::$md5key,static::$data);
            if($period !=0){
                $returnData = static::$Redis->expire('cache_'.static::$typeCache.'_'.static::$group.'_'.static::$md5key,$period);
            }
        }
        static ::staticEmpty();
        return $returnData;
    }
858007
public function setConfig($configOrKey, $config = null) {
        if ($config !== null) {
            $this->config[$configOrKey] = $config;
        }
        else {
            $this->config = ($configOrKey !== null ? $configOrKey : array());
        }
    }
1310949
public function getConfig(string $key)
    {
        //使用回调函数
        if (self::$config instanceof \Closure) {
            return call_user_func(self::$config, $key);
        } //直接注册数组
        elseif (is_array(self::$config)) {
            if (preg_match('@^(\w+)\.(.+)$@', $key, $m)) {
                $name = trim($m[1]);
                $key = trim($m[2]);
                if (isset(self::$config[$name]) && isset(self::$config[$name][$key])) {
                    return self::$config[$name][$key];
                }
                return null;
            }
            return isset(self::$config[$key]) ? self::$config[$key] : null;
        } //使用实例
        elseif (self::$config != null && method_exists(self::$config, 'get')) {
            return self::$config->get($key);
        }
        return null;
    }
1155036
public static function close($config_name)
    {
        if (isset(self::$instance[$config_name])) {
            self::$instance[$config_name]->closeConnection();
            self::$instance[$config_name] = null;
        }
    }
710263
final public static function SetSessionKey( string $key ) : void {
        
        self::SetConfigFromSetter(
                $key,
                self::akSessionKey,
                self::ValidateSessionKey( )
        );
        
    }
53393
public function get($key, $config = [])
    {
    	$key= $this->resolveAlias($key);
    	
        if (isset($this->_singletons[$key])) {  // singleton
            return $this->_singletons[$key];
        } elseif (!isset($this->_definitions[$key])) {  // not set, try build, key tread as className 
            $tryDef = static::formatDefinition($key, $config);
            if (!isset($tryDef['class']) || !class_exists($tryDef['class'])) {
                return null;
            }
            $key = $tryDef['class'];
            return $this->build($key, $config);
        }
        
        $definition = $this->_definitions[$key];
        
        if (is_callable($definition, true)) {// not strict callable, true 参数会使用 'className:method' 也是 callable
            if (!is_callable($definition, false) && is_string($definition)) {
                $definition = $this->resolveCallable($definition); 
            }
            // callable: function($container, $config)
            $object = call_user_func($definition, $this, $config); 
        } elseif (is_array($definition)) {
            $concrete = $definition['class'];
            unset($definition['class']);
			
            if ($config) {
                $definition = array_merge($definition, $config);
            }
            
            $object = $this->build($concrete, $definition);
        } elseif (is_object($definition)) {
            return $this->_singletons[$key] = $definition;
        } else {
            throw new InvalidConfigException("Unexpected object definition type: " . gettype($definition));
        }
		
        // 判断是否存在 _singletons 的 key，不能使用 isset()
        if (array_key_exists($key, $this->_singletons)) {
            // singleton
            $this->_singletons[$key] = $object;
            // set alias
            $this->alias('\\' . get_class($object), $key);
        }

        return $object;
    }
648313
public function setCacheKey($key)
    {
        $key = preg_replace('/[^\da-z]/i', '', $key);
        if (!empty($key)) {
            $this->cacheKey = $key;
        }
    }
828054
public function setConfigStruct(string $configKey, ConfigStruct $configStruct): void
    {
        $this->configStructs[$configKey] = $configStruct;
    }
786539
public function remove(string $key): bool
    {
        if (isset($this->_configValues[$key]) === false) {
            return false;
        }

        unset($this->_configValues[$key]);
        return true;
    }