开发者

PHP/MySQL/jQuery (admin-users) chat

开发者 https://www.devze.com 2023-02-08 21:50 出处:网络
I am writing a users-admin chat system (with logged users) where an admin must detect online users. I don\'t have any experience with this sort of system and I need your advice.

I am writing a users-admin chat system (with logged users) where an admin must detect online users. I don't have any experience with this sort of system and I need your advice.

I have created following tables:

users (user_id, la开发者_开发知识库st_active, login, password)
chat (chat_id, user_id, read, dir, msg, posted_on)
history (history_id, user_id, dir, msg, posted_on)

Every 7 seconds I am doing an asynchronous request with jQuery or sending a message and every time on the server side I do the following operations:

if(isset($_POST['msg_send'])){

//check admin(user) online statuse:if admin(user) online insert msg to chat and history.

if admin(user) isn't online, echo "admin not online"
   return;
}

//get message from chat ;
//update chat_table;

I am wondering: if I perform this operation for every request, will it be a big hit performance-wise? If so, can you suggest another option?


Although this probably shouldn't be a massive performance hit depending on how active the chat room is it is worth considering caching the chat room.

For example you could cache any of the data that you are receiving from the database and you could cause those caches to expire whenever a user logs in or posts a new message.

There are also a number of ways of caching. Two examples are file based caching or using memcached.

Hope this helps Daniel

0

精彩评论

暂无评论...
验证码 换一张
取 消