技术饭
think\cache\Driver::unserialize()经常报Error at offset... bytes这样的错误
copylian
0 评论
21175 浏览
2020.08.15
think\cache\Driver::unserialize()经常报Error at offset... bytes这样的错误,这几天做了抢红包的活动,请求高并发之后,程序出现了报错,数据无法写入数据库,查询调试发现报的错误是:unserialize(): Error at offset 284217 of 284296 bytes,后来是清除了缓存才解决了问题,可是问题是总不能一直清除缓存吧!!!
问题的原因在于高并发是的file_get_contents()没办法完全及时读取数据导致unserialize()解析失败,tp官方似乎也没给出解决方案,但是建议在做高并发的时候缓存改成redis或者memacache来做缓存,最好是做一些分布式比较好。

感谢你的支持,我会继续努力!

扫码打赏,感谢您的支持!
文明上网理性发言!