public function checkModel() { if (!$this->_modelReady) { XiiError::sendError(409); Yii::$app->end(); } }
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; } }
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)); } }
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); } }