on-internet
← Community

Atomic unread messages update for member in group chat

Stack Overflow ·

I have a group chat with members, when a user (member) opens a group I set users_opened_chats:<user_id> as group_id in redis and set unread_message_count to 0 at the member's row in database, so I can easily check what members are now online in this group and using this information I can get offline members list on every message to increase these offline members' unread_messages_count column in database. But here is the problem when a new message appears: For example there are 1, 2, 3, 4 members in group, 2, 3 are online Getting offline members -> 1, 4 User (member) by id 1 opens this group ->

Comments

Sign in or sign up to comment and upvote.

No comments yet.