PHP 解决session死锁的方法
2013-06-20 16:55
711 查看
今天在开发碰到个棘手的问题 。
当异步请求后台处理一个大数据量操作时 请求其他控制器都没返回信息了。。起初以为是Ext 框架设置了ajax同步造成的。
后来发现时session 死锁造成其他控制器在等待session 完成后才能操作。(主要是用户登录判断需要更新session)
当PHP 处理大数据量操作时 不能及时操作完成 这时候又有访问其他控制器或者
异步请求时候会造成session 死锁现象
和同事探讨了下 可使用 session_write_close() 解决此问题
复制代码 代码如下:
Description
void session_write_close ( void )
End the current session and store session data.
Session data is usually stored after your script terminated without the need to call session_write_close(), but as session data is locked to prevent concurrent writes only one script may operate on a session at any time. When using framesets together with sessions you will experience the frames loading one by one due to this locking. You can reduce the time needed to load all the frames by ending the session as soon as all changes to session variables are done.
功能: 结束当前的session 操作 保存session 数据
说的很明白了, 当脚本请求没有调用session_write_close(); 时虽然 session 的数据是存储住了。但是 session Date(也就是session 文件) 是锁住状态
是为了避免 其他应用此时操作session 造成不必要后果 当使用框架时 不同文件可能会不停地操作session 为了不造成其他操作对当前session 的死锁等待
可使用此函数...
当异步请求后台处理一个大数据量操作时 请求其他控制器都没返回信息了。。起初以为是Ext 框架设置了ajax同步造成的。
后来发现时session 死锁造成其他控制器在等待session 完成后才能操作。(主要是用户登录判断需要更新session)
当PHP 处理大数据量操作时 不能及时操作完成 这时候又有访问其他控制器或者
异步请求时候会造成session 死锁现象
和同事探讨了下 可使用 session_write_close() 解决此问题
复制代码 代码如下:
Description
void session_write_close ( void )
End the current session and store session data.
Session data is usually stored after your script terminated without the need to call session_write_close(), but as session data is locked to prevent concurrent writes only one script may operate on a session at any time. When using framesets together with sessions you will experience the frames loading one by one due to this locking. You can reduce the time needed to load all the frames by ending the session as soon as all changes to session variables are done.
功能: 结束当前的session 操作 保存session 数据
说的很明白了, 当脚本请求没有调用session_write_close(); 时虽然 session 的数据是存储住了。但是 session Date(也就是session 文件) 是锁住状态
是为了避免 其他应用此时操作session 造成不必要后果 当使用框架时 不同文件可能会不停地操作session 为了不造成其他操作对当前session 的死锁等待
可使用此函数...
您可能感兴趣的文章:
相关文章推荐
- PHP 解决session死锁的方法
- PHP Manager 安装失败的解决方法, PHP Manager 1.4 for IIS 10,经验证支持windows server 2016版本
- win2003下PHP使用preg_match_all导致apache崩溃问题的解决方法
- php编译安装5.3.2时区错误解决方法
- php unserialize 返回false的解决方法
- windows下PHP中Fatal error Call to undefined function curl_init()的解决方法
- php apache mssql 日期乱码 解决方法
- php插入数据库乱码的解决方法
- 64位win7手动搭建php开发环境Apache+MySQL+php及相关配置,问题解决方法
- 关于PHP语言中的解决Undefined variable: _SESSION的方法
- php发送邮件方法-亲测可用,email.class.php过期解决办法
- PHP_Cooikes不同页面无法传递的解决方法
- PHP数组内存耗用太多问题的解决方法
- php中url传递中文字符,特殊危险字符的解决方法
- PHP生成验证码时“图像因其本身有错无法显示”的解决方法
- php调用存储过程返回结果集,解决can't return a result set in the given context错误的方法
- php 连接mysql连接被重置的解决方法
- php+AJAX传送中文会导致乱码的问题的解决方法
- php+AJAX传送中文会导致乱码的问题的解决方法
- php 缩放gif和png图透明背景变成黑色的解决方法