public function init() { parent::init(); if (is_string($this->ssdb)) { $this->ssdb = \Yii::$app->get($this->ssdb); } elseif (is_array($this->ssdb)) { if (!isset($this->ssdb['class'])) { $this->ssdb['class'] = Connection::className(); } $this->ssdb = \Yii::createObject($this->ssdb); } if (!$this->ssdb instanceof Connection) { throw new InvalidConfigException("Cache::ssdb must be either a Ssdb Connection instance or the application component ID of a ssdb Connection."); } if ($this->cache_keys_hash === "") { $this->{$cache_keys_hash} = substr(md5(Yii::$app->id), 0, 5) . "___"; } }
/** * Initializes the DB connection component. * This method will initialize the [[db]] property to make sure it refers to a valid DB connection. * @throws InvalidConfigException if [[db]] is invalid. */ public function init() { parent::init(); if (is_string($this->db)) { $this->db = Instance::ensure($this->db, Connection::className()); } }