dongliao9018 2013-08-07 14:21
浏览 135
已采纳

使用nodejs + socket.io和mysql聊天

So I want to develop a chat system based on nodejs and socket.io, I have made a prototype and it works, the only thing that is stuck in my mind is how to store the chat messages in the database.

I guess is not a good idea to store a message when a user hits the enter button, because this is live chat you could have 1000 just from a user in 30-60 min.

The question is WHEN to store the data in the database, because I don't think that storing right away when the user hits enter will work on the long term?

The chat works on the same idea as facebook.

  • 写回答

1条回答 默认 最新

  • dongleiwei2182 2013-08-07 14:27
    关注

    If you are not saving the messages at the moment, how do you plan to save them when you want to?

    The messages sent have been delivered to the client and your server no longer has them, and you can't use the client to store them in a database.

    You need to store the messages as the user sends them.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

    报告相同问题?

    悬赏问题

    • ¥15 win11安卓子系统打开谷歌登录不了切使用浏览器显示处于离线状态
    • ¥15 三维直角坐标系下,给定一个平面内四个点坐标,如何将四个点逆时针排序
    • ¥15 UnityWebRequest访问内网地址502
    • ¥20 Python语言来实现牛顿法(Newton's Method)解决非线性(系统)方程的问题。
    • ¥15 matlab控制工业相机采集图像
    • ¥25 R里做折线图和柱状图
    • ¥20 使用kokkos移植项目,遇到问题
    • ¥15 求该问题的Matlab代码
    • ¥15 python下使用pdpbox为何提示has no attribute 'pdp_isolate'?
    • ¥15 求java web病房管理系统项目,用netbeans做的