duande1146 2016-10-19 02:27
浏览 67
已采纳

php sleep redis session_handler while

my application is set "session_handler" to Redis in php.ini,when I write the following code, Redis session storage is nil. My initial idea is a method to deal with time-consuming tasks and write current progressing value into the session variable, another method by ajax polling task progress.

session_start();
$i = 1;
while ($i <= 10)
{

    $_SESSION['process_sync'] = $i;
    $i++;
    sleep(1);
}
$msg = "processing is over";
session_destroy();
print $msg;

I do not know if sleep time is too long, Redis connection will be closed, but 1 second should not be a long time. Or $ _SESSION = "fang xing" assignment, Redis client did not immediately send orders to the Redis server, but in the queue cache, in other words this operation is not blocked, followed by the implementation of sleep, Redis client will put the above Said the queue data discarded? (I assume)

Who can give me talk about the principle :)

  • 写回答

2条回答 默认 最新

  • doushijia5684 2017-06-29 05:35
    关注

    Session will be written to file after request shutdown.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?