I am developing Node.js, Redis based chat application in php. I had an idea about chat logger structure but I required suggestions that how and what to choose proper data structure to create Redis database for logger application.

I know that Redis having lots of data structure options to implement a chat application db. but I have required guideline that how could I create efficient db in Redis for proposed chat architecture.

I should give my proposed idea to implement whole data-structure in Redis but I don't know whether it's efficient of not.

  1. channels (unordered set)

{channel1 , channel2, channel3 ... channelN}

  1. users (unordered set)

{user1, user2, user3, user4, user5 ... userN}

  1. user channel (user related all channels) : (sorted list)
 user1 : {channel1, channel2, channel3}
 user2 : {channel1, channel4, channel7, channel3}
 user3 : {channel2, channel8, channel9}
 user4 : {channel3, channel8}
 user5 : {channel3, channel9, channel10}
  1. message : (list)

{message: message1, sender: user1, receiver: user2, timestamp: 123456}

  1. channel_messages : (channel related messages) : (sorted list)

channe1 : {1, 3, 4, 5, 6} channel2: {7, 8, 9, 10, 11} Above structure fetch all messages of channel.

I have faced following issues in redis :

Redis having intersection commands to get common set but how to fetch unique channels for specific conversations, like user1 and user2 having 2 common channels channel1 and channel3 but now issue that

  • if one to one communication is going on then how could I identified that which channel I shall use for proposed communication becuase set intersection can produce 2 results channel1, channel3.

We seem that, channel1 is used to communication between (user1, user2) channel3 is used to communication among (user1, user2, user3, user4).

So how could I resolve this issue?

Issue Set :
   user1 : {channel1, channel3}
   user2 : {channel1, channel3}   
   user4 : {channel3}
   user5 : {channel3}
  • please don't cross-post: stackoverflow.com/questions/33472130/… – gnat Nov 3 '15 at 13:41
  • @Gnat : I have no purpose to cross post but I have update question with broad scenario you seem that I couldn't find any help so I tried to post a question with different post. I obey your moderation but there is not a meaning to re-post a question. – Dipak chavda Nov 4 '15 at 7:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.