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条)

报告相同问题?

悬赏问题

  • ¥15 C# datagridview 栏位进度
  • ¥15 vue3页面el-table页面数据过多
  • ¥100 vue3中融入gRPC-web
  • ¥15 kali环境运行volatility分析android内存文件,缺profile
  • ¥15 写uniapp时遇到的问题
  • ¥15 vs 2008 安装遇到问题
  • ¥15 matlab有限元法求解梁带有若干弹簧质量系统的固有频率
  • ¥15 找一个网络防御专家,外包的
  • ¥100 能不能让两张不同的图片md5值一样,(有尝)
  • ¥15 informer代码训练自己的数据集,改参数怎么改