I am starting using Redis, and I have participated in the following problem.
I have a bunch of objects, let's say There is no new message to receive, using the values of other clients the problem is that a client In other words, I'm looking for a way to equalize the addition of rows in SQL, and to work with an auto-indexed index. Notes : I can not use the list index, because I have to delete parts of the list often, it will be invalidated is. Current Solutions : The Best Solution I ' But what do I plan to do? I'm trying to use If I am read, then come in correctly, both of you as an id sequence and Using g_message_id to indicate new messages (indicators). One option is to split it into two variables: assign a message identifier and give the second one as a flag to indicate to provide a new message. The client then compares the current / previous value can g_new_message_flag to see if new messages when you are: Possible options, if your client can support it : You want to look at commands, e.g. Cients can publish notifications of new messages to receive notifications and subscribe to one or more message channels. Update 2 : Looking at the new information , Here's what I will do: message in my system every time a new
user adds, I do the following:
INCR is a global variable, say
g_message_id , and
g_message_id returns of INCR value (current code ).
LPUSH New message in a list (including
id and actual message).
g_message_id to check
g_message_id , but no time
LPUSH message before attempting another client To read it, assuming that there is a new message.
watch and
transaction . There is a common usage in Radis - that I am surprised that there is no current answer for this, so I am worried that I am doing something wrong.
& gt; INCR g_message_id (integer) 123 # code with id = 123 code & gt; Multi OK & gt; INCR g_new_message_flag QUEUED & gt; LPUSH g_msg_queue "{\" id \ ": 123, \" msg \ ": \" hey \ "}" trash " EXEC
# to handle the message queue " 123 "," 456 "," 789 ".. # Detects a client that has new messages, then runs it: & gt; Watch G_MSG_Q OK & gt; LRANGE g_msg_queue 0 100000 CAD & gt; DEL g_msg_queue QUEUED & gt; EXEC 1) "789" 2) "456" 3) "123" 2) (integer) 1
Comments
Post a Comment