public function connect() { $conf = Util_Conf::get("redisServer"); $host = $conf["host"]; $port = $conf["port"] ? $conf["port"] : 6379; $this->redis->connect($host, $port); }
/** * @description 保存URL的检查信息 * @param $testId * @param $status */ public function saveCheck($testId, $status, $redirectUrl) { $redis = Util_SRedis::getInstance(); $urlCheckKey = self::URL_CHECK_PREFIX . $testId; $data = $redis->get($urlCheckKey); if ($data) { $data['status'] = $status; $tempData = array_pop($redirectUrl); if ($tempData) { $data['realUrl'] = $tempData['path']; } else { $data['realUrl'] = ''; } $redis->set($urlCheckKey, $data, 600); //10分钟cache //H5版评测,消息通知 if ($data['type'] == self::TYPE_MB) { $msgUrl = Util_Conf::get("mbClientMsgUrl") . '/urlCheck/' . $testId . '?status=' . $status; try { $msgResult = Httpful_Client::getJson($msgUrl); } catch (Exception $e) { //todo } } //如果是api,并且url验证成功,下发任务 if ($data['type'] == self::TYPE_API && $status == self::STATUS_FINISHED) { $evaluateModel = new EvaluateModel(); $evaluateModel->start($data['url'], $testId, $data['userId']); } } }
public static function getInstance() { if (self::$db) { return self::$db; } $conf = Util_Conf::get("mongoServer"); $connection = new MongoClient($conf); self::$db = $connection->ypc; return self::$db; }
public static function getFromDB($strKey) { $redis = Util_SRedis::getInstance(); $prefix = Util_Conf::get("dataPrefix"); $redisKey = $prefix . "config_in_mongo"; $config = $redis->get($redisKey); if (!$config) { $mongo = Util_MongoDB::getInstance(); $collection = $mongo->config; $config = $collection->findOne(); $redis->set($redisKey, $config); } $configKeyList = explode(".", $strKey); foreach ($configKeyList as $str) { $config = $config[$str]; } return $config; }
private function __construct() { $this->redis = new Redis(); $conf = Util_Conf::get("redisServer"); $host = $conf["host"]; $port = $conf["port"]; $this->redis->connect($host, $port); }