/** * 设置保存缓存 * @param $id * @param $data * @return bool */ public function set($id, $data) { try { if (trim($id) != '') { $cache_data['time'] = microtime(TRUE); $cache_data['data'] = $data; $file = $this->_getCacheFile($id); if (is_writable($file)) { @file_put_contents($file, $this->_safe_head . serialize($cache_data)); } else { YucMonitor::report("REPORT_0010"); } return TRUE; } } catch (Exception $exc) { return FALSE; } }
/** * 持久化数组 * @param $file * @param $array * @return bool */ function saveArrayFile($file, $array) { $cache_data = var_export($array, TRUE); if (file_exists($file) && is_writable($file)) { @file_put_contents($file, '<?php return ' . $cache_data . ';?>'); return TRUE; } else { YucMonitor::report("REPORT_0009"); return FALSE; } }
/** * POST发送请求数据 * @return array */ private function doPost() { $client = new YucRequest(YApp::getConfig('YUC_SERVICE_NAME'), YApp::getConfig('YUC_SERVICE_PORT')); $client->setTimeout(YApp::getConfig('YUC_CLIENT_TIMEOUT')); //设置超时 $client->post(YApp::getConfig('YUC_REQUEST_PATH'), $this->_local->getPostData()); YLog::Write('请求:' . YApp::getConfig('YUC_SERVICE_NAME') . YApp::getConfig('YUC_REQUEST_PATH') . ';返回状态 :' . $client->getStatus() . ';POST请求返回的数据:' . $client->getContent(), YLog::DEBUG); $ret_back = json_decode($client->getContent(), TRUE); if (!is_array($ret_back)) { YucMonitor::report("REPORT_0004", $client->getContent()); } return array('status' => $client->getStatus(), 'content' => $ret_back); }