예제 #1
0
 public function checkModel()
 {
     if (!$this->_modelReady) {
         XiiError::sendError(409);
         Yii::$app->end();
     }
 }
예제 #2
0
 private static function getFromRedis()
 {
     if (!self::$_getFromRedis) {
         return;
     }
     if (!empty(self::$_outputData)) {
         return;
     }
     if (self::$cacheId == '') {
         return;
     }
     $redis = @stream_socket_client(Yii::$app->redis->hostname . ':' . Yii::$app->redis->port, $errno, $errstr, 1);
     XiiError::ignoreError();
     if (!$redis) {
         self::$_requestError[] = 'Fail to connect Redis Service';
     } else {
         self::$_outputData = XiiUtil::JsonDecode(Yii::$app->redis->get(self::$_outputName));
         self::$_dataFrom = self::DATA_FROM_REDIS;
     }
 }
예제 #3
0
 public function actionDelete()
 {
     if ($this->_requestCurrent != 'DELETE') {
         XiiError::sendError(400);
         Yii::$app->end();
     }
     if (!empty($this->_requestIds)) {
         XiiResponse::run($this->_modelClass->del($this->_requestIds));
     } else {
         XiiResponse::run($this->_modelClass->del($this->_requestData));
     }
 }
예제 #4
0
 private static function saveToRedis()
 {
     if (!self::$_saveToRedis) {
         return;
     }
     if (empty(self::$_outputData['data'])) {
         return;
     }
     if (self::$_outputName == '') {
         return;
     }
     $redis = @stream_socket_client(Yii::$app->redis->hostname . ':' . Yii::$app->redis->port, $errno, $errstr, 1);
     XiiError::ignoreError();
     if (!$redis) {
         self::$_responseError[] = 'Fail to connect Redis Service';
     } else {
         Yii::$app->redis->set(self::$_outputName, Yii::$app->response->content);
     }
 }