CN108737246B - Message issuing method, device, storage medium and server - Google Patents

Message issuing method, device, storage medium and server Download PDF

Info

Publication number
CN108737246B
CN108737246B CN201810426840.2A CN201810426840A CN108737246B CN 108737246 B CN108737246 B CN 108737246B CN 201810426840 A CN201810426840 A CN 201810426840A CN 108737246 B CN108737246 B CN 108737246B
Authority
CN
China
Prior art keywords
message
placeholder
chain
sequence number
messages
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810426840.2A
Other languages
Chinese (zh)
Other versions
CN108737246A (en
Inventor
刘硕
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Dajia Internet Information Technology Co Ltd
Original Assignee
Beijing Dajia Internet Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Dajia Internet Information Technology Co Ltd filed Critical Beijing Dajia Internet Information Technology Co Ltd
Priority to CN201810426840.2A priority Critical patent/CN108737246B/en
Publication of CN108737246A publication Critical patent/CN108737246A/en
Application granted granted Critical
Publication of CN108737246B publication Critical patent/CN108737246B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L51/00User-to-user messaging in packet-switching networks, transmitted according to store-and-forward or real-time protocols, e.g. e-mail
    • H04L51/04Real-time or near real-time messaging, e.g. instant messaging [IM]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L51/00User-to-user messaging in packet-switching networks, transmitted according to store-and-forward or real-time protocols, e.g. e-mail
    • H04L51/06Message adaptation to terminal or network requirements
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L51/00User-to-user messaging in packet-switching networks, transmitted according to store-and-forward or real-time protocols, e.g. e-mail
    • H04L51/21Monitoring or handling of messages
    • H04L51/214Monitoring or handling of messages using selective forwarding

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The invention provides a message issuing method of instant communication, which comprises the following steps: acquiring instant messaging messages, and storing the messages in a memory based on a zset data structure of Redis to form a message chain; receiving a command of deleting a message, and acquiring a corresponding serial number of the deleting message in the message chain; setting the corresponding position of the message chain as a placeholder according to the sequence number; and issuing the message according to the message chain. In the embodiment of the invention, all operations are finished in the memory, and the execution speed is very high; the client side can identify the data with the hole filling when finding the placeholder in the received issued message, and believes that the authenticity of the issued message cannot be checked again to avoid filling. The invention also provides a message issuing device, a storage medium and a server for instant messaging.

Description

Message issuing method, device, storage medium and server
Technical Field
The invention relates to the technical field of message processing, in particular to a message issuing method, a device, a storage medium and a server for instant messaging.
Background
Almost all the social software on the market currently provides a one-to-one based chat function in the chat function, and some provide a message withdrawal function, so that the message disappears and can not be seen any more. How to ensure the sequence of the messages and how to ensure that the new message chain can be normally concatenated after the messages are cancelled is a research topic. Also, differences in storage and algorithms of servers of different products can result in significant differences in efficiency and performance.
In the existing method for combining messages, a server stores the messages in a database table, a unique serial number is generated for each message through self-adding ID, each message is connected in series through the unique serial number to form a session, and if A deletes one message, the server deletes the database record corresponding to the message serial number; when a user pulls a message from a client, the user needs to perform range query through SQL. The self-increment ID and range query based on the database belongs to disk IO operation, and the message processing performance is poor; the deletion of the message causes the discontinuity of the serial number of the message, so that when a client pulls the multiple devices at the client, the client cannot confirm that the pulled message data is lost or the server message data is defective, secondary pulling may be performed, and unnecessary overhead causes pressure to the server.
Disclosure of Invention
The invention provides a method, a device and a server for issuing instant messaging messages aiming at the defects of the existing mode.
The invention provides a message issuing method of instant communication, which comprises the following steps:
acquiring instant messaging messages, and storing the messages in a memory based on a zset data structure of Redis to form a message chain;
receiving a command of deleting a message, and acquiring a corresponding serial number of the deleting message in the message chain;
setting the corresponding position of the message chain as a placeholder according to the sequence number;
and issuing the message according to the message chain.
Preferably, the message is composed of: a message sender, a message receiver, a message content type and a message content; the placeholder adopts two nodes of min and max to identify the range.
Preferably, the zset data structure based on Redis stores the message to a memory to form a message chain, including:
converting the message into binary information, storing the binary information in a memory according to a storage structure of an ordered set, and acquiring elements corresponding to the binary information;
correspondingly binding each element by adopting a unique score;
and saving the sequence number of the ordered set by adopting a fraction to realize the conversion of the binary information into a message chain form.
Preferably, the query command for the message chain is: zrangebycoreabmsgs < minSeq > < maxSeq >;
where zrangebyscore denotes a command to query a result by a score, abmsgs denotes a message chain between saved ab, minSeq denotes a minimum sequence number, and maxSeq denotes a maximum sequence number.
Preferably, the setting the corresponding position of the message chain as a placeholder according to the sequence number includes:
and searching a position corresponding to the sequence number in the message chain, and adding the elements with the same scores to the position again to form a placeholder.
Preferably, the adding command for re-adding the elements with the same score is as follows: zaddambsgs seq1< place _ holder _ msg >;
where zadd represents a command to add elements of the same score, abmsgs represents saving a chain of messages between ab, seq1 represents a sequence number, and place _ holder _ msg represents a placeholder.
Preferably, the minimum sequence number and the maximum sequence number of the placeholder are both the sequence numbers corresponding to the placeholder.
Preferably, before issuing a message according to the message chain, the method further includes:
confirming that at least two continuous placeholders exist in the message chain, and combining the at least two continuous placeholders into one placeholder.
Preferably, the merging the at least two consecutive placeholders into one placeholder includes:
obtaining the maximum sequence number of the at least two consecutive placeholders;
obtaining a minimum sequence number of the at least two consecutive placeholders;
and forming a placeholder according to the maximum sequence number and the minimum sequence number.
The invention also provides a message issuing device for instant communication, which comprises:
a message storage module: the message chain management method comprises the steps of obtaining instant messaging messages, and storing the messages to a memory based on a zset data structure of Redis to form a message chain;
a serial number acquisition module: the instruction for receiving the deletion message is used for acquiring a corresponding serial number of the deletion message in the message chain;
a placeholder setting module: the message chain is used for setting the corresponding position of the message chain as a placeholder according to the sequence number;
a message issuing module: and the message chain is used for issuing messages according to the message.
Preferably, the message saving module includes:
a storage unit: the message processing device is used for converting the message into binary information, storing the binary information in a memory according to a storage structure of an ordered set, and acquiring elements corresponding to the binary information;
a binding unit: the unique score is used for correspondingly binding each element;
a transformation unit: and the serial number of the ordered set is saved by adopting a fraction, so that the binary information is converted into a message chain form.
Preferably, the method further comprises, before the message issuing module:
and (3) occupying and combining modules: the device is used for confirming that at least two continuous placeholders exist in the message chain and combining the at least two continuous placeholders into one placeholder.
Preferably, the placeholder merge module comprises:
a first acquisition unit: for obtaining a maximum sequence number of the at least two consecutive placeholders;
a second acquisition unit: for obtaining a minimum sequence number of the at least two consecutive placeholders;
a recombination unit: for composing a placeholder based on the maximum sequence number and the minimum sequence number.
The present invention also provides a computer-readable storage medium, on which a computer program is stored, which when executed by a processor implements a message issuing method according to any one of claims 1 to 9.
The present invention also provides a server, comprising:
one or more processors;
a memory;
one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, the one or more programs configured to: executing the message issuing method according to any one of claims 1 to 9.
In the specific implementation process of the invention, by acquiring the instant messaging message, saving the message to the memory based on the zset data structure of Redis to form a message chain; receiving a command of deleting a message, and acquiring a corresponding serial number of the deleting message in the message chain; setting the corresponding position of the message chain as a placeholder according to the sequence number; and issuing the message according to the message chain. All operations are finished in the memory, and the execution speed is very high; the client side can identify the data with the hole filling when finding the placeholder in the received issued message, and believes that the authenticity of the issued message cannot be checked again to avoid filling.
Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention.
Drawings
The foregoing and/or additional aspects and advantages of the present invention will become apparent and readily appreciated from the following description of the embodiments, taken in conjunction with the accompanying drawings of which:
fig. 1 is a schematic flow chart of a message issuing method of instant messaging according to a first embodiment of the present invention;
fig. 2 is a flowchart illustrating a message issuing method of instant messaging according to a second embodiment of the present invention;
FIG. 3 is a schematic flow chart of the present invention for storing messages in a memory and forming a message chain;
FIG. 4 is a flow diagram illustrating the process of the present invention for merging at least two consecutive placeholders into one placeholder;
fig. 5 is a schematic structural component diagram of a message issuing apparatus of instant messaging in a third embodiment of the present invention;
fig. 6 is a schematic structural component diagram of an instant messaging message issuing device in a fourth embodiment of the present invention;
fig. 7 is a schematic structural diagram of a server in a fifth embodiment of the present invention, illustrating a message delivery method for performing instant messaging.
Detailed Description
Reference will now be made in detail to embodiments of the present invention, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to the same or similar elements or elements having the same or similar function throughout. The embodiments described below with reference to the drawings are illustrative only and should not be construed as limiting the invention.
As used herein, the singular forms "a", "an", "the" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "comprises" and/or "comprising," when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof. It will be understood that when an element is referred to as being "connected" or "coupled" to another element, it can be directly connected or coupled to the other element or intervening elements may also be present. Further, "connected" or "coupled" as used herein may include wirelessly connected or wirelessly coupled. As used herein, the term "and/or" includes all or any element and all combinations of one or more of the associated listed items.
It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. It will be further understood that terms, such as those defined in commonly used dictionaries, should be interpreted as having a meaning that is consistent with their meaning in the context of the prior art and will not be interpreted in an idealized or overly formal sense unless expressly so defined herein.
The first embodiment is as follows:
referring to fig. 1, fig. 1 is a flowchart illustrating a message issuing method of instant messaging according to a first embodiment of the present invention.
As shown in fig. 1, a method for issuing an instant messaging message includes the following steps:
s11: acquiring instant messaging messages, and storing the messages in a memory based on a zset data structure of Redis to form a message chain;
the instant messaging refers to services such as internet messages and the like which can be sent and received instantly, the instant messaging messages are messages sent from one party to the other party, when a user carries out instant messaging, a server providing instant messaging can obtain the instant messaging messages in real time, the messages comprise message sending parties, message receiving parties, message content types and message contents, and placeholders formed by the instant messaging messages are subjected to range identification by adopting two nodes of min and max.
The definition and the placeholder of the instant communication message are subjected to range identification by adopting two nodes of min and max, and the range identification is realized by the following pseudo codes:
Figure BDA0001652347420000061
Figure BDA0001652347420000071
the above pseudo-code description describes that a Message is a composition including a sender, a receiver, and content _ type and content, and a normal Message is represented by its own type and content; the placeholders have own special type distinguishing messages, and the data structure PlaceHolderMessage of the message itself represents the range by min and max nodes, which provides guarantee for continuous merging of multiple placeholders in the subsequent step.
And saving the message to a memory based on a zset data structure of Redis to form a message chain.
In the embodiment of the present invention, the storage is based on zeset (ordered set) in the Redis (key-value storage system (database)), where the zeset is a set that can be ordered, and each element member has a unique score bound to it correspondingly inside the set, that is, a specific binary message of the message content can be stored by the element member, and seq (serial number) can be stored by score, thereby realizing the storage in the form of a message chain.
The query command for the chain storage form message is: zrangebycoreabmsgs < minSeq > < maxSeq >;
where zrangbyscore represents a command to query the result by score, abmsgs represents saving the chain of messages between ab, minSeq represents the smallest sequence number, maxSeq represents the largest sequence number, the command will return all scores between two values and the memberships (elements) to which the scores are bound.
Referring to fig. 3, fig. 3 is a schematic flow chart illustrating a process of storing messages in a memory and forming a message chain according to the present invention.
As shown in fig. 3, the detailed steps are as follows:
s111: converting the message into binary information, storing the binary information in a memory according to a storage structure of an ordered set, and acquiring elements corresponding to the binary information;
the message stored in the memory needs to be firstly converted into binary information to be stored, so that the message is converted into the binary information, the binary information is stored in the memory based on a zset data structure of Redis, the Redis is a key-value storage system (database), zset is an ordered set, the binary information is stored in the memory according to the structure of the ordered set, the binary information can be correspondingly linked in the memory by adopting a unique element, and the element corresponding to the message can be acquired through the binary information.
S112: correspondingly binding each element by adopting a unique score;
and binding each element by using a unique score in the ordered set in the memory storage, so that the corresponding element can be inquired through the unique score, and the corresponding message can be acquired through the corresponding element.
S113: and saving the sequence number of the ordered set by adopting a fraction to realize the conversion of the binary information into a message chain form.
The serial numbers in the ordered set are stored by adopting the scores which are correspondingly bound by the elements, and the binary information can be converted into the message chain by adopting a continuous chain formed after the scores are stored because the serial numbers in the ordered set are continuous.
S12: receiving a command of deleting a message, and acquiring a corresponding serial number of the deleting message in the message chain;
when one of two parties of instant messaging sends a message to the other party, and finds that the sent message may have description errors or improper word, the sent message is requested to be deleted or withdrawn, firstly, a command for deleting or withdrawing the message is sent, and after a server for providing instant messaging for the two parties of a user receives the command for deleting or withdrawing the message, a corresponding serial number of the message which the user needs to delete or withdraw in a message chain is obtained in the message chain.
S13: setting the corresponding position of the message chain as a placeholder according to the sequence number;
specifically, a position corresponding to the sequence number is searched in the message chain, and elements with the same score are added to the position again to form a placeholder.
In the specific implementation process, after a message sender deletes or withdraws a message instruction, the database deletes the corresponding message, obtains a serial number corresponding to the deleted message, then searches the corresponding deleted message in zset (ordered set) in the database, and then newly adds the same score's member as the original zset (ordered set); the re-addition is realized by the command as follows: zaddambsgs seq1< place _ holder _ msg >;
where zadd represents a command to add elements of the same score, abmsgs represents saving a chain of messages between ab, seq1 represents a sequence number, and place _ holder _ msg represents a placeholder.
After the placeholder is formed, the minimum sequence number and the maximum sequence number of the placeholder are both the sequence numbers corresponding to the placeholder.
S14: and issuing the message according to the message chain.
In the specific implementation process, the server sends the message chain with the placeholders to the user requesting to send the message.
It should be noted here that A, B two or more users coexist in instant messaging, when sending a message through instant messaging, if one finds that the sent message may have misexpression or other reasons, it requests to withdraw the message or delete the message, when another party requests to issue the message, the place holder is set for the position of the deleted or withdrawn message through the above steps, so that the message chain is kept continuous, and the other party requesting to issue the message can know that the other party has the withdrawn or deleted message, and does not consider the message lost.
In the specific implementation process of the invention, all operations are completed in the memory, and the execution speed is very high; the client side can identify the data with the hole filling when finding the placeholder in the received issued message, and believes that the authenticity of the issued message cannot be checked again to avoid filling.
Example two:
referring to fig. 2, fig. 2 is a flowchart illustrating a message issuing method of instant messaging according to a second embodiment of the present invention.
As shown in fig. 2, a method for issuing an instant messaging message includes the following steps:
s21: acquiring instant messaging messages, and storing the messages in a memory based on a zset data structure of Redis to form a message chain;
the instant messaging refers to services such as internet messages and the like which can be sent and received instantly, the instant messaging messages are messages sent from one party to the other party, when a user carries out instant messaging, a server providing instant messaging can obtain the instant messaging messages in real time, the messages comprise message sending parties, message receiving parties, message content types and message contents, and placeholders formed by the instant messaging messages are subjected to range identification by adopting two nodes of min and max.
The definition and the placeholder of the instant communication message are subjected to range identification by adopting two nodes of min and max, and the range identification is realized by the following pseudo codes:
Figure BDA0001652347420000101
Figure BDA0001652347420000111
the above pseudo-code description describes that a Message is a composition including a sender, a receiver, and content _ type and content, and a normal Message is represented by its own type and content; the placeholders have own special type distinguishing messages, and the data structure PlaceHolderMessage of the message itself represents the range by min and max nodes, which provides guarantee for continuous merging of multiple placeholders in the subsequent step.
And saving the message to a memory based on a zset data structure of Redis to form a message chain.
In the embodiment of the present invention, the storage is based on zeset (ordered set) in the Redis (key-value storage system (database)), where the zeset is a set that can be ordered, and each element member has a unique score bound to it correspondingly inside the set, that is, a specific binary message of the message content can be stored by the element member, and seq (serial number) can be stored by score, thereby realizing the storage in the form of a message chain.
The query command for the chain storage form message is: zrangebycoreabmsgs < minSeq > < maxSeq >;
where zrangbyscore represents a command to query the result by score, abmsgs represents saving the chain of messages between ab, minSeq represents the smallest sequence number, maxSeq represents the largest sequence number, the command will return all scores between two values and the memberships (elements) to which the scores are bound.
Referring to fig. 3, fig. 3 is a schematic flow chart illustrating a process of storing messages in a memory and forming a message chain according to the present invention.
As shown in fig. 3, the detailed steps are as follows:
s111: converting the message into binary information, storing the binary information in a memory according to a storage structure of an ordered set, and acquiring elements corresponding to the binary information;
the message stored in the memory needs to be firstly converted into binary information to be stored, so that the message is converted into the binary information, the binary information is stored in the memory based on a zset data structure of Redis, the Redis is a key-value storage system (database), zset is an ordered set, the binary information is stored in the memory according to the structure of the ordered set, the binary information can be correspondingly linked in the memory by adopting a unique element, and the element corresponding to the message can be acquired through the binary information.
S112: correspondingly binding each element by adopting a unique score;
and binding each element by using a unique score in the ordered set in the memory storage, so that the corresponding element can be inquired through the unique score, and the corresponding message can be acquired through the corresponding element.
S113: and saving the sequence number of the ordered set by adopting a fraction to realize the conversion of the binary information into a message chain form.
The serial numbers in the ordered set are stored by adopting the scores which are correspondingly bound by the elements, and the binary information can be converted into the message chain by adopting a continuous chain formed after the scores are stored because the serial numbers in the ordered set are continuous.
S22: receiving a command of deleting a message, and acquiring a corresponding serial number of the deleting message in the message chain;
when one of two parties of instant messaging sends a message to the other party, and finds that the sent message may have description errors or improper word, the sent message is requested to be deleted or withdrawn, firstly, a command for deleting or withdrawing the message is sent, and after a server for providing instant messaging for the two parties of a user receives the command for deleting or withdrawing the message, a corresponding serial number of the message which the user needs to delete or withdraw in a message chain is obtained in the message chain.
S23: setting the corresponding position of the message chain as a placeholder according to the sequence number;
specifically, a position corresponding to the sequence number is searched in the message chain, and elements with the same score are added to the position again to form a placeholder.
In the specific implementation process, after a message sender deletes or withdraws a message instruction, the database deletes the corresponding message, obtains a serial number corresponding to the deleted message, then searches the corresponding deleted message in zset (ordered set) in the database, and then newly adds the same score's member as the original zset (ordered set); the re-addition is realized by the command as follows: zaddambsgs seq1< place _ holder _ msg >;
where zadd represents a command to add elements of the same score, abmsgs represents saving a chain of messages between ab, seq1 represents a sequence number, and place _ holder _ msg represents a placeholder.
After the placeholder is formed, the minimum sequence number and the maximum sequence number of the placeholder are both the sequence numbers corresponding to the placeholder.
S24: confirming that at least two continuous placeholders exist in the message chain, and combining the at least two continuous placeholders into one placeholder;
in a specific implementation process, whether at least two continuous placeholders exist in the message chain is confirmed by traversing the message chain, if not, the step directly enters S25, and if so, at least two continuous placeholders are merged into a new placeholder.
Merging at least two continuous placeholders, wherein the maximum sequence number of the at least two continuous placeholder messages is the maximum sequence number of the latest placeholder message, namely, taking max _ seq of the at least two continuous placeholder messages as max _ seq of the new placeholder message; the minimum sequence number in the at least two continuous placeholder messages is the minimum sequence number of the new placeholder message, namely, the min _ seq in the at least two continuous placeholder messages is taken as the min _ seq of the new placeholder message; thereby, at least two continuous placeholder messages are merged into a new placeholder message, and the representation range of the new placeholder message is the maximum sequence number and the minimum sequence number of the original at least two continuous placeholder messages.
The method comprises the following specific steps:
table 1 is a chain of messages A and B stored in zset, increasing from left to right, i.e., chronologically, with messages 101, 103,104, and 107 deleted (whether A or B deleted)
TABLE 1
Figure BDA0001652347420000141
The 103 and 104 messages become a new placeholder message, the new placeholder message is identified by a min _ seq ═ 103 and a max _ seq ═ 104 sequence number, which is called a hole filling, the client side obtains the data with the hole to know that the seq range in the middle of the normal loaded message is really free of data, and the server is not required to verify whether the missing message exists.
Still alternatively, another example:
if 100 is a normal message, 100 is indicated as member (100 ), and if 97, 98, 99 three normal messages are deleted, they can be combined into member (97, 99).
Referring to fig. 4, fig. 4 is a schematic flow chart illustrating the process of combining at least two consecutive placeholders into one placeholder according to the present invention.
As shown in fig. 4, the detailed steps are as follows:
s241: obtaining the maximum sequence number of the at least two consecutive placeholders;
and adopting the maximum sequence number in the at least two continuous placeholder messages for the at least two continuous placeholder messages, namely obtaining the max _ seq in the at least two continuous placeholder messages.
S242: obtaining a minimum sequence number of the at least two consecutive placeholders;
the minimum sequence number in the at least two consecutive placeholder messages is the min _ seq in the at least two consecutive placeholder messages.
S243: and forming a placeholder according to the maximum sequence number and the minimum sequence number.
Combining at least two consecutive placeholders into a new placeholder requires the minimum and maximum sequence numbers of the new placeholder, and in S241 and S242, acquiring the minimum and maximum sequence numbers of the new placeholder, and using the minimum and maximum sequence numbers to form a new placeholder. If 103 and 104 are combined into a new placeholder message, the new placeholder message is identified with a min _ seq ═ 103, max _ seq ═ 104 sequence number, which is referred to as member (103, 104).
S25: and issuing the message according to the message chain.
In the specific implementation process, the server sends the message chain with the placeholders to the user requesting to send the message.
In the specific implementation process of the invention, all operations are completed in the memory, and the execution speed is very high; the client side can identify the data with hole filling when finding the placeholder in the received issued message, and believes that the authenticity of the issued message cannot be checked again to avoid filling; the scheme based on merging continuous loopholes can greatly reduce the number of issued holes and reduce the bandwidth occupation.
Example three:
referring to fig. 5, fig. 5 is a schematic structural diagram of a message issuing device for instant messaging according to a third embodiment of the present invention.
As shown in fig. 5, an instant messaging message issuing apparatus includes:
the message storage module 11: the message chain management method comprises the steps of obtaining instant messaging messages, and storing the messages to a memory based on a zset data structure of Redis to form a message chain;
the instant messaging refers to services such as internet messages and the like which can be sent and received instantly, the instant messaging messages are messages sent from one party to the other party, when a user carries out instant messaging, a server providing instant messaging can obtain the instant messaging messages in real time, the messages comprise message sending parties, message receiving parties, message content types and message contents, and placeholders formed by the instant messaging messages are subjected to range identification by adopting two nodes of min and max.
The definition and the placeholder of the instant communication message are subjected to range identification by adopting two nodes of min and max, and the range identification is realized by the following pseudo codes:
Figure BDA0001652347420000161
the above pseudo-code description describes that a Message is a composition including a sender, a receiver, and content _ type and content, and a normal Message is represented by its own type and content; the placeholders have own special type distinguishing messages, and the data structure PlaceHolderMessage of the message itself represents the range by min and max nodes, which provides guarantee for continuous merging of multiple placeholders in the subsequent step.
And saving the message to a memory based on a zset data structure of Redis to form a message chain.
In the embodiment of the present invention, the storage is based on zeset (ordered set) in the Redis (key-value storage system (database)), where the zeset is a set that can be ordered, and each element member has a unique score bound to it correspondingly inside the set, that is, a specific binary message of the message content can be stored by the element member, and seq (serial number) can be stored by score, thereby realizing the storage in the form of a message chain.
The query command for the chain storage form message is: zrangebycoreabmsgs < minSeq > < maxSeq >;
where zrangbyscore represents a command to query the result by score, abmsgs represents saving the chain of messages between ab, minSeq represents the smallest sequence number, maxSeq represents the largest sequence number, the command will return all scores between two values and the memberships (elements) to which the scores are bound.
Wherein, the message storage module 11 further includes:
a storage unit: the message processing device is used for converting the message into binary information, storing the binary information in a memory according to a storage structure of an ordered set, and acquiring elements corresponding to the binary information;
the message stored in the memory needs to be firstly converted into binary information to be stored, so that the message is converted into the binary information, the binary information is stored in the memory based on a zset data structure of Redis, the Redis is a key-value storage system (database), zset is an ordered set, the binary information is stored in the memory according to the structure of the ordered set, the binary information can be correspondingly linked in the memory by adopting a unique element, and the element corresponding to the message can be acquired through the binary information.
A binding unit: the unique score is used for correspondingly binding each element;
and binding each element by using a unique score in the ordered set in the memory storage, so that the corresponding element can be inquired through the unique score, and the corresponding message can be acquired through the corresponding element.
A transformation unit: and the serial number of the ordered set is saved by adopting a fraction, so that the binary information is converted into a message chain form.
The serial numbers in the ordered set are stored by adopting the scores which are correspondingly bound by the elements, and the binary information can be converted into the message chain by adopting a continuous chain formed after the scores are stored because the serial numbers in the ordered set are continuous.
The serial number obtaining module 12: the instruction for receiving the deletion message is used for acquiring a corresponding serial number of the deletion message in the message chain;
when one of two parties of instant messaging sends a message to the other party, and finds that the sent message may have description errors or improper word, the sent message is requested to be deleted or withdrawn, firstly, a command for deleting or withdrawing the message is sent, and after a server for providing instant messaging for the two parties of a user receives the command for deleting or withdrawing the message, a corresponding serial number of the message which the user needs to delete or withdraw in a message chain is obtained in the message chain.
Placeholder setting module 13: the message chain is used for setting the corresponding position of the message chain as a placeholder according to the sequence number;
specifically, a position corresponding to the sequence number is searched in the message chain, and elements with the same score are added to the position again to form a placeholder.
In the specific implementation process, after a message sender deletes or withdraws a message instruction, the database deletes the corresponding message, obtains a serial number corresponding to the deleted message, then searches the corresponding deleted message in zset (ordered set) in the database, and then newly adds the same score's member as the original zset (ordered set); the re-addition is realized by the command as follows: zaddambsgs seq1< place _ holder _ msg >;
where zadd represents a command to add elements of the same score, abmsgs represents saving a chain of messages between ab, seq1 represents a sequence number, and place _ holder _ msg represents a placeholder.
After the placeholder is formed, the minimum sequence number and the maximum sequence number of the placeholder are both the sequence numbers corresponding to the placeholder.
The message issuing module 14: and the message chain is used for issuing messages according to the message.
In the specific implementation process, the server sends the message chain with the placeholders to the user requesting to send the message.
In the specific implementation process of the invention, all operations are completed in the memory, and the execution speed is very high; the client side can identify the data with the hole filling when finding the placeholder in the received issued message, and believes that the authenticity of the issued message cannot be checked again to avoid filling.
Example four:
referring to fig. 6, fig. 6 is a schematic structural composition diagram of an instant messaging message issuing device according to a fourth embodiment of the present invention.
As shown in fig. 6, an instant messaging message issuing apparatus includes:
the message saving module 21: the message chain management method comprises the steps of obtaining instant messaging messages, and storing the messages to a memory based on a zset data structure of Redis to form a message chain;
the serial number obtaining module 22: the instruction for receiving the deletion message is used for acquiring a corresponding serial number of the deletion message in the message chain;
placeholder setting module 23: the message chain is used for setting the corresponding position of the message chain as a placeholder according to the sequence number;
for the above specific implementation of the message saving module 21, the sequence number obtaining module 22, and the placeholder setting module 23, reference may be made to the first to third embodiments, and details are not described here.
Placeholder merge module 24: the device is used for confirming that at least two continuous placeholders exist in the message chain and combining the at least two continuous placeholders into one placeholder.
In a specific implementation process, whether at least two continuous placeholders exist in the message chain is determined by traversing the message chain, if not, the message directly enters the message issuing module 25 to directly issue the message, and if so, the at least two continuous placeholders are combined to form a new placeholder.
Merging at least two continuous placeholders, wherein the maximum sequence number of the at least two continuous placeholder messages is the maximum sequence number of the latest placeholder message, namely, taking max _ seq of the at least two continuous placeholder messages as max _ seq of the new placeholder message; the minimum sequence number in the at least two continuous placeholder messages is the minimum sequence number of the new placeholder message, namely, the min _ seq in the at least two continuous placeholder messages is taken as the min _ seq of the new placeholder message; thereby, at least two continuous placeholder messages are merged into a new placeholder message, and the representation range of the new placeholder message is the maximum sequence number and the minimum sequence number of the original at least two continuous placeholder messages.
The method comprises the following specific steps:
table 1 is a chain of messages A and B stored in zset, increasing from left to right, i.e., chronologically, with messages 101, 103,104, and 107 deleted (whether A or B deleted)
TABLE 1
Figure BDA0001652347420000201
The 103 and 104 messages become a new placeholder message, the new placeholder message is identified by a min _ seq ═ 103 and a max _ seq ═ 104 sequence number, which is called a hole filling, the client side obtains the data with the hole to know that the seq range in the middle of the normal loaded message is really free of data, and the server is not required to verify whether the missing message exists.
Still alternatively, another example:
if 100 is a normal message, 100 is indicated as member (100 ), and if 97, 98, 99 three normal messages are deleted, they can be combined into member (97, 99).
The placeholder merge module 14 further comprises:
a first acquisition unit: for obtaining a maximum sequence number of the at least two consecutive placeholders;
and adopting the maximum sequence number in the at least two continuous placeholder messages for the at least two continuous placeholder messages, namely obtaining the max _ seq in the at least two continuous placeholder messages.
A second acquisition unit: for obtaining a minimum sequence number of the at least two consecutive placeholders;
the minimum sequence number in the at least two consecutive placeholder messages is the min _ seq in the at least two consecutive placeholder messages.
A recombination unit: for composing a placeholder based on the maximum sequence number and the minimum sequence number.
Combining at least two consecutive placeholders into a new placeholder requires the minimum and maximum sequence numbers of the new placeholder, and in S241 and S242, acquiring the minimum and maximum sequence numbers of the new placeholder, and using the minimum and maximum sequence numbers to form a new placeholder. If 103 and 104 are combined into a new placeholder message, the new placeholder message is identified with a min _ seq ═ 103, max _ seq ═ 104 sequence number, which is referred to as member (103, 104).
The message issuing module 15: and the message chain is used for issuing messages according to the message.
In the specific implementation process, the server sends the message chain with the placeholders to the user requesting to send the message.
In the specific implementation process of the invention, all operations are completed in the memory, and the execution speed is very high; the client side can identify the data with hole filling when finding the placeholder in the received issued message, and believes that the authenticity of the issued message cannot be checked again to avoid filling; the scheme based on merging continuous loopholes can greatly reduce the number of issued holes and reduce the bandwidth occupation.
Example five:
in the computer-readable storage medium provided in the embodiment of the present invention, a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the message issuing method according to any technical scheme is implemented. The computer-readable storage medium includes, but is not limited to, any type of disk including floppy disks, hard disks, optical disks, CD-ROMs, and magneto-optical disks, ROMs (Read-Only memories), RAMs (Random AcceSS memories), EPROMs (EraSable Programmable Read-Only memories), EEPROMs (Electrically EraSable Programmable Read-Only memories), flash memories, magnetic cards, or optical cards. That is, a storage device includes any medium that stores or transmits a message in a form readable by a device (e.g., a computer, a cell phone), and may be a read-only memory, a magnetic or optical disk, or the like.
Referring to fig. 7, fig. 7 is a schematic diagram illustrating a server component structure of a message issuing method for performing instant messaging according to a fifth embodiment of the present invention.
As shown in fig. 7, the server includes a processor 702, a memory 703, an input unit 704, and a display unit 705. The structural elements shown in fig. 7 do not constitute a limitation on all servers and may have more or fewer components than those shown in fig. 7, or some of the components may be combined.
The memory 703 may be used to store the application program 701 and various functional modules, and the processor 702 executes the application program 701 stored in the memory 703, thereby executing various functional applications of the device and data processing. The memory may be internal or external memory, or include both internal and external memory. The memory may comprise read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), flash memory, or random access memory. The external memory may include a hard disk, a floppy disk, a ZIP disk, a usb-disk, a magnetic tape, etc. The disclosed memory includes, but is not limited to, these types of memory. The disclosed memory is by way of example only and not by way of limitation.
The input unit 704 is used for receiving input of signals and receiving keywords input by a user. The input unit 704 may include a touch panel and other input devices. The touch panel can collect touch operations of a user on or near the touch panel (for example, operations of the user on or near the touch panel by using any suitable object or accessory such as a finger, a stylus and the like) and drive the corresponding connecting device according to a preset program; other input devices may include, but are not limited to, one or more of a physical keyboard, function keys (e.g., play control keys, switch keys, etc.), a trackball, a mouse, a joystick, and the like. The display unit 705 may be used to display information input by a user or information provided to the user and various menus of the terminal device. The display unit 705 may take the form of a liquid crystal display, an organic light emitting diode, or the like. The processor 702 is a control center of the terminal device, connects various parts of the entire device using various interfaces and lines, and performs various functions and processes data by operating or executing software programs and/or modules stored in the memory 702 and calling data stored in the memory.
As one embodiment, the computer device includes: one or more processors 702, a memory 703, one or more applications 701, wherein the one or more applications 701 are stored in the memory 703 and configured to be executed by the one or more processors 702, and the one or more programs 701 are configured to perform the message issuing method in the above embodiments.
The server provided by the embodiment of the present invention can implement the embodiment of the message chain issuing method provided above, and for specific function implementation, please refer to the description in the detailed method embodiment, which is not described herein again.
In the specific implementation process of the invention, all operations are completed in the memory, and the execution speed is very high; the client side can identify the data with hole filling when finding the placeholder in the received issued message, and believes that the authenticity of the issued message cannot be checked again to avoid filling; the scheme based on merging continuous loopholes can greatly reduce the number of issued holes and reduce the bandwidth occupation.
It should be understood that, although the steps in the flowcharts of the figures are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and may be performed in other orders unless explicitly stated herein. Moreover, at least a portion of the steps in the flow chart of the figure may include multiple sub-steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, which are not necessarily performed in sequence, but may be performed alternately or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
The foregoing is only a partial embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.

Claims (12)

1. A message issuing method of instant messaging is characterized by comprising the following steps:
acquiring instant messaging messages, and storing the messages in a memory based on a zset data structure of Redis to form a message chain;
receiving a command of deleting a message, and acquiring a corresponding serial number of the deleting message in the message chain;
setting the corresponding position of the message chain as a placeholder according to the sequence number;
sending down the message according to the message chain;
wherein, the zset data structure based on Redis stores the message to a memory to form a message chain, including:
converting the message into binary information, storing the binary information in a memory according to a storage structure of an ordered set, and acquiring elements corresponding to the binary information;
correspondingly binding each element by adopting a unique score;
the serial number of the ordered set is saved by adopting a fraction, so that the binary information is converted into a message chain form;
the setting the corresponding position of the message chain as a placeholder according to the sequence number comprises:
and searching a position corresponding to the sequence number of the deleted message in the message chain, and adding the elements with the same scores of the original ordered set again at the position to form a placeholder.
2. The message issuing method according to claim 1, wherein the message is composed of: a message sender, a message receiver, a message content type and a message content; the placeholder adopts two nodes of min and max to identify the range.
3. The message issuing method according to claim 1, wherein the query command for the message chain is: zrangebybore abmsgs < minSeq > < maxSeq >;
where zrangebyscore denotes a command to query a result by a score, abmsgs denotes a message chain between saved ab, minSeq denotes a minimum sequence number, and maxSeq denotes a maximum sequence number.
4. The message issuing method according to claim 1, wherein the add command for re-adding the elements with the same score is: zadd abmsgs seq1< place _ holder _ msg >;
where zadd represents a command to add elements of the same score, abmsgs represents saving a chain of messages between ab, seq1 represents a sequence number, and place _ holder _ msg represents a placeholder.
5. The message issuing method according to claim 1, wherein the minimum sequence number and the maximum sequence number of the placeholder are both the sequence numbers corresponding to the placeholder.
6. The message issuing method according to claim 1, wherein before issuing a message according to the message chain, further comprising:
confirming that at least two continuous placeholders exist in the message chain, and combining the at least two continuous placeholders into one placeholder.
7. The message issuing method according to claim 6, wherein said combining said at least two consecutive placeholders into one placeholder comprises:
obtaining the maximum sequence number of the at least two consecutive placeholders;
obtaining a minimum sequence number of the at least two consecutive placeholders;
and forming a placeholder according to the maximum sequence number and the minimum sequence number.
8. An instant messaging message issuing device, comprising:
a message storage module: the message chain management method comprises the steps of obtaining instant messaging messages, and storing the messages to a memory based on a zset data structure of Redis to form a message chain;
a serial number acquisition module: the instruction for receiving the deletion message is used for acquiring a corresponding serial number of the deletion message in the message chain;
a placeholder setting module: the message chain is used for setting the corresponding position of the message chain as a placeholder according to the sequence number;
a message issuing module: used for sending down the message according to the message chain;
wherein the message saving module comprises:
a storage unit: the message processing device is used for converting the message into binary information, storing the binary information in a memory according to a storage structure of an ordered set, and acquiring elements corresponding to the binary information;
a binding unit: the unique score is used for correspondingly binding each element;
a transformation unit: the serial number of the ordered set is saved by adopting a fraction, and the binary information is converted into a message chain form;
the placeholder setting module is specifically configured to search a position in the message chain corresponding to the sequence number of the deletion message in the message chain, and add an element with the same score as that of the original ordered set again at the position to form a placeholder.
9. The message issuing device according to claim 8, further comprising, before the message issuing module:
and (3) occupying and combining modules: the device is used for confirming that at least two continuous placeholders exist in the message chain and combining the at least two continuous placeholders into one placeholder.
10. The message issuing apparatus according to claim 9, wherein the placeholder merge module comprises:
a first acquisition unit: for obtaining a maximum sequence number of the at least two consecutive placeholders;
a second acquisition unit: for obtaining a minimum sequence number of the at least two consecutive placeholders;
a recombination unit: for composing a placeholder based on the maximum sequence number and the minimum sequence number.
11. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, implements the message issuing method according to any one of claims 1 to 7.
12. A server, characterized in that it comprises:
one or more processors;
a memory;
one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, the one or more programs configured to: executing the message issuing method according to any one of claims 1 to 7.
CN201810426840.2A 2018-05-07 2018-05-07 Message issuing method, device, storage medium and server Active CN108737246B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810426840.2A CN108737246B (en) 2018-05-07 2018-05-07 Message issuing method, device, storage medium and server

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810426840.2A CN108737246B (en) 2018-05-07 2018-05-07 Message issuing method, device, storage medium and server

Publications (2)

Publication Number Publication Date
CN108737246A CN108737246A (en) 2018-11-02
CN108737246B true CN108737246B (en) 2021-02-02

Family

ID=63937008

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810426840.2A Active CN108737246B (en) 2018-05-07 2018-05-07 Message issuing method, device, storage medium and server

Country Status (1)

Country Link
CN (1) CN108737246B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111327915A (en) * 2020-02-21 2020-06-23 北京字节跳动网络技术有限公司 Method and device for determining message arrival rate
CN111669313B (en) * 2020-05-29 2022-05-03 广西东信互联科技有限公司 Method for storing and synchronizing instant communication system message

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10346542B2 (en) * 2012-08-31 2019-07-09 Verint Americas Inc. Human-to-human conversation analysis
CN102984676B (en) * 2012-11-29 2015-07-08 华为终端有限公司 Method and terminal for processing message session
US20160057093A1 (en) * 2014-08-19 2016-02-25 Samsung Electronics Co., Ltd. Method and apparatus for displaying content
CN105608103A (en) * 2015-10-16 2016-05-25 北京奇虎科技有限公司 Transforming method and device of data storing structure
CN105490919B (en) * 2015-11-24 2019-11-08 小米科技有限责任公司 Message cancelling method and device

Also Published As

Publication number Publication date
CN108737246A (en) 2018-11-02

Similar Documents

Publication Publication Date Title
US10579595B2 (en) Method and device for calling a distributed file system
US7584264B2 (en) Data storage and retrieval systems and related methods of storing and retrieving data
CN103190123B (en) For the method and apparatus distributing the message of issue
US8296372B2 (en) Method and system for merging electronic messages
CN102710763B (en) The method and system of a kind of distributed caching pond, burst and Failure Transfer
US20220035786A1 (en) Distributed database management system with dynamically split b-tree indexes
CN108737246B (en) Message issuing method, device, storage medium and server
CN112685499B (en) Method, device and equipment for synchronizing flow data of working service flow
US8352442B2 (en) Determination of an updated data source from disparate data sources
US11755555B2 (en) Storing an ordered associative array of pairs using an append-only storage medium
CN111552934A (en) Database access method and device
CN109976924A (en) Interface call method and device
CN113886494A (en) Message storage method, device, equipment and computer readable medium for instant messaging
CN110519212B (en) Communication forwarding system based on anonymous inference
CN111046106A (en) Cache data synchronization method, device, equipment and medium
US10025859B2 (en) Method and system for second-degree friend query
US10855563B2 (en) Supplementing log messages with metadata
US20170286440A1 (en) Method, business processing server and data processing server for storing and searching transaction history data
CN104125254A (en) Method and system for obtaining platform user data
CN101442458B (en) System and method for sending sequence type data
EP2751720B1 (en) Processing communications data
US20140108420A1 (en) Index creation method and system
CN111259031A (en) Data updating method, device, equipment and storage medium
CN101872356B (en) Method and system for improving processing performance of memory database
CN101527691B (en) Reporting and processing method for status information and network server

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant