id = $id; $this->sid = $sid; } public function __destruct() { unset($this->content); } public function init() { $url = Yii::$app->params['feixiaohao_domain'] . Yii::$app->params['feixiaohao_page']['currencies'] . $this->sid . '/'; $ch = new Curl(); $content = $ch->get($url, true); $this->content = str_replace([' ', ' '], '', $content); } /** * @return mixed */ public function getPrice() { $result = Yii::$app->cache->get($this->cache_key_prifx . $this->sid . '_price'); if ($result === false) { if (empty($this->content)) { $this->init(); } $pattern = '/