Exemplo n.º 1
0
 /**
  * @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']);
         }
     }
 }
Exemplo n.º 2
0
 public static function getInstance()
 {
     if (!$instance) {
         self::$instance = new Util_SRedis();
     }
     return self::$instance;
 }
Exemplo n.º 3
0
 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;
 }