加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > PHP > 正文

php – 不能从redis读取

发布时间:2020-05-25 09:38:11 所属栏目:PHP 来源:互联网
导读:我有一个服务器长时间运行的应用程序存储过程像这样: routes.php文件 Route::post(cloud/slice/{modelfileid}, CloudController@slice);Route::get(cloud/slice/sliceProgress, CloudController@sliceProgress); slice()函数的一部分: while

我有一个服务器长时间运行的应用程序存储过程像这样:

routes.php文件

Route::post('cloud/slice/{modelfileid}','CloudController@slice');
Route::get('cloud/slice/sliceProgress','CloudController@sliceProgress');

slice()函数的一部分:

while($s = fgets($pipes[2]))
{
    if(strpos($s,"Progress:") !== FALSE)
    {
        Log::info(100 * substr($s,-10,4) . '%');
        $this->redis->SET('sliceProgress' . $uid,100 * substr($s,4) . '%');

    }
}

和我的客户每0.5秒请求重新进行的这个:

public function sliceProgress()
{
    if (!isset($_SESSION["uid"]))
        return Redirect::to('cloud');
    $uid = $_SESSION["uid"];
    return Response::json(array('status' => 'success','data' => array('progress' => $this->redis->GET('sliceProgress' . $uid))));
}

$interval(function()
{
    $scope.refreshProgress();
},500);

但客户获得进度请求将持续到100%,而不是100%的进度.也就是说,当服务器切片应用程序完成时,我得到进度响应.我想Lailavel在处理片时不处理第二个请求.

Edited:
I use below code to get the redis in the slice() after the redis->SET works well,this output the sliceProgress realtime.

Log::info($this->redis->GET('sliceProgress' . $uid));

尝试在后台进程中运行此代码,如异步队列或crons
while($s = fgets($pipes[2]))
{
if(strpos($s,"Progress:") !== FALSE)
{
    Log::info(100 * substr($s,4) . '%');
    $this->redis->SET('sliceProgress' . $uid,4) . '%');

}
}

(编辑:安卓应用网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读