Vin*_*815 4 php mysql ajax notifications
我有一个具有通知功能的项目,我想出了如何实时获取通知的想法.我的想法是每秒查询一次表.我有一个通知表,所以每当客户端添加一些东西时它会插入到通知表中,然后另一个客户端通过查询它来获取通知.我使用ajax来做到这一点.
每秒查询一次表格是不是很好,或者这是不好的编程习惯?我只在localhost中使用它,这很好.当网站上线时,这种想法是否会产生负面影响?
提前谢谢你的答案.
每秒ping数据库并不是理想的做法; 您可以实现数据库触发器和HTML5 websockets /推送通知的组合:http: //html5hacks.com/blog/2013/04/21/push-notifications-to-the-browser-with-server-sent-events/
http://www.abrandao.com/2013/06/25/websockets-using-modern-html5-technology-for-true-server-push/
http://pusher.com/tutorials/html5_realtime_push_notifications