php – 不能从redis读取

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

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) . '%');

}
}

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...