base_url . '/api/v1/ticker/24hr'; $res = $curl->get($api, false);//json if (is_array($res)) { foreach ($res as $item) { $this->redis->sadd($this->supported_symbol, strtolower($item['symbol'])); } } } public function setQuotation() { $curl = new Curl(); $api = $this->base_url . '/app/tradeMarket/coinPrice'; $res = $curl->get($api, false); if (is_array($res) && isset($res['obj'])) { $data = $res['obj']; foreach ($data as $key => $item) { $low = isset($item['minPrice']) ? $item['minPrice'] : 0; $high = isset($item['maxPrice']) ? $item['maxPrice'] : 0; $last = isset($item['currentExchangPrice']) ? $item['currentExchangPrice'] : 0; $open = isset($item['openPrice']) ? $item['openPrice'] : 0; $vol = isset($item['transactionSum']) ? $item['transactionSum'] : 0; $cache_key = strtolower($this->quotation_prefix . str_replace('_', '', $key)); $this->redis->hmset($cache_key, 'low', $low, 'high', $high, 'last', $last, 'open', $open, 'vol', $vol); $this->redis->sadd($this->supported_symbol, strtoupper(str_replace('_', '', $key))); } } } }