예제 #1
0
파일: Redis.php 프로젝트: Genffy/calculate
 public function connect()
 {
     $conf = Util_Conf::get("redisServer");
     $host = $conf["host"];
     $port = $conf["port"] ? $conf["port"] : 6379;
     $this->redis->connect($host, $port);
 }
예제 #2
0
파일: Index.php 프로젝트: Genffy/calculate
 /**
  * @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']);
         }
     }
 }
예제 #3
0
 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;
 }
예제 #4
0
파일: Conf.php 프로젝트: Genffy/calculate
 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;
 }
예제 #5
0
파일: SRedis.php 프로젝트: Genffy/calculate
 private function __construct()
 {
     $this->redis = new Redis();
     $conf = Util_Conf::get("redisServer");
     $host = $conf["host"];
     $port = $conf["port"];
     $this->redis->connect($host, $port);
 }