Disclosure of Invention
The embodiment of the disclosure provides at least one message processing scheme, which solves the problem that a user cannot receive point-to-point messages simultaneously when different devices log in an account of the same live broadcast room on one hand, and can improve the message processing speed on the other hand.
In a first aspect, an embodiment of the present disclosure provides a message processing method, which is applied to a server, where the message processing method includes:
when a write-in message is received, acquiring information of a receiving end corresponding to the write-in message; the information of the receiving end comprises a user identifier of the receiving end and a room identifier of a virtual room corresponding to the write-in message;
acquiring the current user number of the virtual room according to the room identification, and selecting a target storage system according to the current user number of the virtual room;
when the selected target storage system is a first type storage system, writing the write-in message into a corresponding target storage queue in the first type storage system corresponding to the user identifier, the room identifier and the equipment type identifier aiming at each preset equipment type identifier; the first type storage system is used for storing write messages of virtual rooms with the corresponding current user number reaching a set number threshold.
In a possible implementation manner, before the writing the write message into the corresponding target storage queue in the first type storage system together with the user identifier, the room identifier and the device type identifier, the message processing method further includes:
searching whether a target storage queue corresponding to the user identifier, the room identifier and each equipment type identifier exists in the first type storage system;
and when the target storage queue does not exist, creating a target storage queue associated with the target identification, the room identification and each device type identification corresponding to the write message in the first type storage system.
In one possible implementation, the message processing method further includes:
when the selected target storage system is a second type storage system, writing the write message into a fragment corresponding to the room identifier in the second type storage system based on the room identifier of the virtual room; the second type storage system is used for storing write-in messages of virtual rooms, the number of corresponding current users of which does not reach a set number threshold value; each slice in the second type of storage system contains a plurality of circular lists for storing write messages, each circular list containing a plurality of storage locations for storing write messages.
In a possible embodiment, the writing the write message into a segment corresponding to the room identifier in a distributed system based on the room identifier of the virtual room includes:
based on the room identifier, selecting a segment corresponding to the room identifier from the segments of the second type storage system;
selecting a target circular list corresponding to the room identifier and the user identifier in the selected slice corresponding to the room identifier based on the room identifier and the user identifier corresponding to the write message;
writing the write message to the target circular list.
In a possible implementation, the message processing method further includes:
responding to a message extraction request sent by any receiving terminal, acquiring the current user number of a virtual room according to the room identifier of the virtual room contained in the message extraction request, and determining a target storage system corresponding to the message extraction request according to the current user number of the virtual room;
and extracting the write-in message corresponding to the message extraction request from the target storage system corresponding to the message extraction request.
In a possible implementation manner, the extracting, from the target storage system corresponding to the message extraction request, the write message corresponding to the message extraction request includes:
acquiring message extraction position information contained in the message extraction request;
and according to the initial extraction position indicated by the information extraction position information, extracting the write-in information which corresponds to the information extraction request and is positioned behind the initial extraction position from the target storage system corresponding to the information extraction request.
In one possible implementation, the extracting, from the target storage system corresponding to the message extraction request, the write message corresponding to the message extraction request and located after the initial extraction location includes:
and when determining that the number of the write messages which correspond to the message extraction request and are positioned behind the initial extraction position exceeds a preset message extraction threshold value in a target storage system corresponding to the message extraction request, extracting the number of the write messages which correspond to the message extraction request and are positioned behind the initial extraction position from the write messages which correspond to the message extraction request and are positioned behind the initial extraction position.
In a possible implementation manner, when the target storage system is a first type storage system, after the target storage system corresponding to the message extraction request extracts the write message corresponding to the message extraction request, the message processing method further includes:
deleting the extracted write message in the target storage system.
In a second aspect, an embodiment of the present disclosure provides a message processing apparatus, which is applied to a server, and includes:
the acquisition module is used for acquiring the information of a receiving end corresponding to the write-in message when the write-in message is received; the information of the receiving end comprises a user identifier of the receiving end and a room identifier of a virtual room corresponding to the write-in message;
the selection module is used for acquiring the current user number of the virtual room according to the room identifier and selecting a target storage system according to the current user number of the virtual room;
a writing module, configured to, when the selected target storage system is a first type storage system, write the write message into a corresponding target storage queue in the first type storage system, where the target storage queue corresponds to the user identifier, the room identifier, and the device type identifier, for each preset device type identifier; the first type storage system is used for storing write messages of virtual rooms with the corresponding current user number reaching a set number threshold.
In a possible implementation manner, before the writing the write message into the corresponding target storage queue in the first type storage system together with the user identifier, the room identifier and the device type identifier, the writing module is further configured to:
searching whether a target storage queue corresponding to the user identifier, the room identifier and each equipment type identifier exists in the first type storage system;
and when the target storage queue does not exist, creating a target storage queue associated with the target identification, the room identification and each device type identification corresponding to the write message in the first type storage system.
In one possible implementation, the write module is further configured to:
when the selected target storage system is a second type storage system, writing the write message into a segment corresponding to the room identifier in the second type storage system based on the room identifier of the virtual room; the second type storage system is used for storing write-in messages of virtual rooms, the number of corresponding current users of which does not reach a set number threshold value; each slice in the second type of storage system contains a plurality of circular lists for storing write messages, each circular list containing a plurality of storage locations for storing write messages.
In one possible embodiment, the writing module, when configured to write the write message into a slice in a distributed system corresponding to the room identification based on the room identification of the virtual room, includes:
based on the room identifier, selecting a segment corresponding to the room identifier from the segments of the second type storage system;
selecting a target circular list corresponding to the room identifier and the user identifier in the selected slice corresponding to the room identifier based on the room identifier and the user identifier corresponding to the write message;
writing the write message to the target circular list.
In a possible implementation, the message processing apparatus further includes an extraction module, and the extraction module is configured to:
responding to a message extraction request sent by any receiving terminal, acquiring the current user number of a virtual room according to the room identifier of the virtual room contained in the message extraction request, and determining a target storage system corresponding to the message extraction request according to the current user number of the virtual room;
and extracting the write-in message corresponding to the message extraction request from the target storage system corresponding to the message extraction request.
In a possible implementation manner, the extracting module, when configured to extract the write message corresponding to the message extraction request from the target storage system corresponding to the message extraction request, includes:
acquiring message extraction position information contained in the message extraction request;
and according to the initial extraction position indicated by the information extraction position information, extracting the write-in information which corresponds to the information extraction request and is positioned behind the initial extraction position from the target storage system corresponding to the information extraction request.
In one possible embodiment, the extracting module, when configured to extract the write message corresponding to the message extraction request and located after the initial extraction location from the target storage system corresponding to the message extraction request, includes:
and when determining that the number of the write messages which correspond to the message extraction request and are positioned behind the initial extraction position exceeds a preset message extraction threshold value in a target storage system corresponding to the message extraction request, extracting the number of the write messages which correspond to the message extraction request and are positioned behind the initial extraction position from the write messages which correspond to the message extraction request and are positioned behind the initial extraction position.
In a possible implementation manner, the message processing apparatus further includes a deleting module, when the target storage system is the first type storage system, after the extracting module extracts the write message corresponding to the message extraction request from the target storage system corresponding to the message extraction request, the deleting module is configured to:
deleting the extracted write message in the target storage system.
In a third aspect, an embodiment of the present disclosure provides an electronic device, including: a processor, a memory and a bus, the memory storing machine-readable instructions executable by the processor, the processor and the memory communicating over the bus when the electronic device is operating, the machine-readable instructions when executed by the processor performing the steps of the message processing method according to the first aspect.
In a fourth aspect, the disclosed embodiments provide a computer-readable storage medium having stored thereon a computer program, which, when executed by a processor, performs the steps of the message processing method according to the first aspect.
According to the message processing scheme provided by the embodiment of the disclosure, when a write-in message is received, a receiving end to which the write-in message is sent is determined, a user identifier of the receiving end and a room identifier of a virtual room corresponding to the write-in message are obtained, wherein the user identifier can be used as a user name for a user to log in the virtual room, such as a user name for logging in a live broadcast room, the room identifier of the virtual room can be used for identifying the live broadcast room, then the current user number of the virtual room can be obtained according to the room identifier, then a target storage system is selected according to the current user number of the virtual room, it can be seen that when the write-in message is stored, the write-in message can be stored in different types of storage systems according to the current user number in the virtual room, such as in a scene, a hot live broadcast room in which the current user number reaches a threshold value and a common live broadcast room in which the current user number does not reach the threshold value, and for the write-in message to be sent to the two different live broadcast rooms, the different types of storage systems can be classified and stored, so that the service performance of each type of storage system can be ensured, and the message processing efficiency can be improved.
In addition, when the selected target storage system is a first type storage system, the first type storage system is used for storing write messages of virtual rooms, the number of which reaches a set number threshold, of the corresponding current users, namely, the write messages are hot live broadcast rooms, the write messages can be written into a target storage queue corresponding to user identifiers, room identifiers and equipment type identifiers in the first type storage system according to each preset equipment type identifier, for example, the pre-stored equipment type identifiers comprise mobile phone type identifiers and non-mobile phone type identifiers, the write messages can be written into a target storage queue 1 corresponding to the mobile phone type identifiers, and meanwhile, the write messages can be written into a target storage queue 2 corresponding to the non-mobile phone type identifiers, so that when a user logs in live broadcast rooms on mobile phone equipment and non-mobile phone equipment through the user identifiers at the same time, the write messages sent to the user can be extracted from different target storage queues through the mobile phone equipment and the non-mobile phone equipment respectively, and the effect that the user can simultaneously log in point-to point messages in the same live broadcast room through different equipment is achieved.
In order to make the aforementioned objects, features and advantages of the present disclosure more comprehensible, preferred embodiments accompanied with figures are described in detail below.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present disclosure more clear, the technical solutions of the embodiments of the present disclosure will be described clearly and completely with reference to the drawings in the embodiments of the present disclosure, and it is obvious that the described embodiments are only a part of the embodiments of the present disclosure, not all of the embodiments. The components of the embodiments of the present disclosure, as generally described and illustrated in the figures herein, could be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present disclosure, presented in the figures, is not intended to limit the scope of the claimed disclosure, but is merely representative of selected embodiments of the disclosure. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the disclosure without making creative efforts, shall fall within the protection scope of the disclosure.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.
In some application scenarios, for example, in a live broadcast scenario, after logging in a live broadcast room, a user may receive a peer-to-peer message, for example, receive PK wheat connection prompt information, or receive a prompt message when a certain activity task is completed, but when the user logs in the live broadcast room through different terminal devices at the same time, the user may only receive the peer-to-peer message on one terminal device, that is, when the same user logs in the live broadcast room through multiple terminal devices at the same time, the user may not receive the peer-to-peer message on multiple terminal devices at the same time.
In addition, the Server firstly stores the received point-to-point messages for the received point-to-point messages, then extracts the stored point-to-point messages and sends the stored point-to-point messages to the receiving end based on an extraction request of the receiving end, and the messages are stored by completely depending on a Remote Dictionary service (Redis).
Based on the above research, the present disclosure provides a message processing scheme, where when a write message is received, a receiving end to which the write message is to be sent is determined, and a user identifier of the receiving end and a room identifier of a virtual room corresponding to the write message are obtained, where the user identifier may be used as a user name for a user to log in the virtual room, such as a user name for logging in a live broadcast room, and the room identifier of the virtual room may be used to identify the live broadcast room, and then according to the room identifier, a current user number of the virtual room may be obtained, and then a target storage system is selected according to the current user number of the virtual room.
In addition, when the selected target storage system is a first type storage system, the first type storage system is used for storing write-in messages of virtual rooms, the number of which reaches a set number threshold, corresponding to the current number of users, namely, when the selected target storage system is a hot live broadcast room, the write-in messages can be written into a target storage queue corresponding to a user identifier, a room identifier and a device type identifier in the first type storage system according to each preset device type identifier, for example, the pre-stored device type identifier comprises a mobile phone type identifier and a non-mobile phone type identifier, the write-in messages can be written into a target storage queue 1 corresponding to the mobile phone type identifier, and the write-in messages can be written into a target storage queue 2 corresponding to the non-mobile phone type identifier, so that when a user logs in live broadcast rooms on mobile phone devices and non-mobile phone devices through the user identifier at the same time, the write-in messages sent to the different target storage queues can be extracted through the mobile phone devices and the non-mobile phone account devices respectively, and the effect that the user can receive the live broadcast messages at the same time when the user logs in different devices.
To facilitate understanding of the present embodiment, a detailed description is first given of a message processing method disclosed in the embodiments of the present disclosure, where an execution subject of the message processing method provided in the embodiments of the present disclosure is generally a computer device with certain computing capability, such as a server or other processing device, and in some possible implementations, the message processing method may be implemented by a processor calling a computer readable instruction stored in a memory.
Referring to fig. 1, a flowchart of a message processing method provided in the embodiment of the present disclosure is shown, where the message processing method includes the following steps S101 to S103:
s101, when receiving a write-in message, acquiring information of a receiving end corresponding to the write-in message; the information of the receiving end comprises a user identifier of the receiving end and a room identifier of the virtual room corresponding to the written message.
The write message herein refers to a point-to-point message, that is, a message sent to a specific receiver, and the write message may include a message indicating the receiver to which the write message is sent, specifically, a user identifier of the receiver included in the message of the receiver may be used to indicate to which user the write message is sent, and a room identifier of a virtual room included in the message of the receiver may be used to indicate the virtual room to which the write message is sent.
S102, acquiring the current user number of the virtual room according to the room identification, and selecting a target storage system according to the current user number of the virtual room.
When receiving the write-in message, the server temporarily stores the write-in message in the storage system, and waits for the receiving end to extract the write-in message, specifically, when storing the write-in message, the server preferably can acquire the current number of users logged in the virtual room corresponding to the room identifier at this time according to the room identifier, that is, the heat of the virtual room (live broadcast room) can be determined, and then can determine a target storage system where the write-in message should be stored according to the current number of users of the virtual room.
S103, when the selected target storage system is the first type storage system, aiming at each preset device type identification, writing the write-in message into a corresponding target storage queue in the first type storage system corresponding to the user identification, the room identification and the device type identification.
The first type storage system is used for storing write messages of virtual rooms with the corresponding current user number reaching a set number threshold value, namely, the write messages to be sent to the hot live broadcast rooms.
The first type storage system is configured to store write messages of virtual rooms in which the number of current users reaches a set number threshold, and may be a Remote Dictionary service (Remote Dictionary Server, redis).
The server may preset multiple device type identifiers, for example, when a user logs in a live broadcast room, a device normally used by the user includes a mobile phone device or a non-mobile phone device (computer), where the device type identifier is used to indicate a device type used for logging in the live broadcast room, and the device type may specifically include a mobile phone type and a non-mobile phone type, so that when a write-in message is stored, the write-in message may be stored in a target storage queue corresponding to the user identifier, the room identifier, and each device type identifier, respectively.
For example, the preset device type identifiers include two types, which are a mobile phone type identifier and a non-mobile phone type identifier, respectively, so that the first type storage system may include two target storage queues, may include a first target storage queue corresponding to the user identifier, the room identifier, and the mobile phone type identifier, and may include a second target storage queue corresponding to the user identifier, the room identifier, and the non-mobile phone type identifier.
When the first type storage system is Redis, the write-in message is written into a first target storage queue corresponding to the user identifier, the room identifier and the mobile phone type identifier in Redis, and is written into a second target storage queue corresponding to the user identifier, the room identifier and the non-mobile phone type identifier in Redis.
The above is a message processing method provided for S101 to S103, where when a write message is received, a receiving end to which the write message is to be sent is determined, and a user identifier of the receiving end and a room identifier of a virtual room corresponding to the write message are obtained, where the user identifier may be used as a user name of a user logging in the virtual room (live room), and the room identifier of the virtual room may be used to distinguish live rooms, and then according to the room identifier, a current user number of the virtual room, that is, a heat degree of the live room, may be obtained, and then a target storage system is selected according to the current user number of the virtual room.
In addition, when the selected target storage system is a first type storage system, the first type storage system is used for storing write-in messages of virtual rooms, the number of which reaches a set number threshold, corresponding to the current number of users, namely, when the selected target storage system is a hot live broadcast room, the write-in messages can be written into a target storage queue corresponding to a user identifier, a room identifier and a device type identifier in the first type storage system according to each preset device type identifier, for example, the pre-stored device type identifier comprises a mobile phone type identifier and a non-mobile phone type identifier, the write-in messages can be written into a target storage queue 1 corresponding to the mobile phone type identifier, and the write-in messages can be written into a target storage queue 2 corresponding to the non-mobile phone type identifier, so that when a user logs in live broadcast rooms on mobile phone devices and non-mobile phone devices through the user identifier at the same time, the write-in messages sent to the different target storage queues can be extracted through the mobile phone devices and the non-mobile phone account devices respectively, and the effect that the user can receive the live broadcast messages at the same time when the user logs in different devices.
The above-described S101 to S103 will be described with reference to specific embodiments.
For the above S103, that is, when the selected target storage system is the first type storage system, for each preset device type identifier, writing the write message into the target storage queue in the first type storage system together with the user identifier, the room identifier, and the device type identifier, specifically, the writing is as follows:
when a write-in message is received, checking a user identifier and a room identifier corresponding to the write-in message, then finding a target storage queue corresponding to the user identifier and the room identifier in a first type storage system, wherein the number of the target storage queue is the same as the number of the device type identifiers, for example, two device type identifiers of devices are arranged in advance, the number of the target storage queues corresponding to the user identifier and the room identifier is two, and then writing the write-in message into the two target storage queues respectively.
For example, if the user identifier corresponding to the write message is ABC001, the corresponding room identifier is 6556789, the preset device type identifiers include a cell phone type identifier 01 and a non-cell phone type identifier 00, and the write message is "active task complete", then find a first target storage queue corresponding to key = ABC001:6556789 and a second target storage queue corresponding to key = ABC001: 6556789.
Specifically, when writing a write message into the target storage queue, the write message may be written in the following manner:
(1) Acquiring a current writing position in a target storage queue;
(2) And writing the write message into the target storage queue according to the current write position in the target storage queue.
Each write message in the target storage queue may be stored according to the write time sequence of the write message, so that when the write message is received, the current write position in the target storage queue may be determined according to the write time of the write message and the write time corresponding to each write message in the target storage queue, that is, the write message is stored in the target storage queue according to the time sequence of the received write message.
Of course, if there is no target storage queue associated with the user identifier and the room identifier corresponding to the write message in the first type storage system, and when the write message is received for the first time, the target storage queue may be established in the first type storage system, that is, before the write message is written into the corresponding target storage queue in the first type storage system corresponding to the user identifier, the room identifier, and the device type identifier in step S103, the message processing method provided in the embodiment of the present disclosure further includes:
(1) Searching whether a target storage queue corresponding to a user identifier, a room identifier and each equipment type identifier exists in a first type storage system;
(2) Upon determining that a target storage queue does not exist, creating a target storage queue associated with a target identification, a room identification, and each device type identification corresponding to the write message in the first type storage system.
In this case, when the user identifier and the room identifier corresponding to the write message are received for the first time, a target storage queue with a number corresponding to the number of the device type identifiers may be created in the Redis according to the number of the device type identifiers preset, and if the device type identifiers include two device type identifiers, namely, a mobile phone type identifier and a non-mobile phone type identifier, a first target storage queue associated with the target identifier, the room identifier and the mobile phone type identifier corresponding to the write message and a second target storage queue associated with the target identifier, the room identifier and the non-mobile phone type identifier corresponding to the write message are created.
In another implementation, the message processing method provided in the embodiment of the present disclosure further includes:
when the selected target storage system is a second type storage system, writing the write-in message into a segment corresponding to the room identifier in the second type storage system based on the room identifier of the virtual room; the second type storage system is used for storing write messages of virtual rooms corresponding to which the number of current users does not reach the set number threshold.
Wherein each slice in the second type of storage system contains a plurality of circular lists for storing write messages, each circular list containing a plurality of storage locations for storing write messages.
That is, when the number of the current users in the obtained virtual room does not reach the set number threshold according to the room identifier, a second type storage system may be selected, where the second type storage system may be a distributed storage system, and the distributed storage system may include a plurality of segments for storing messages.
Specifically, each slice in the second type storage system includes a plurality of circular lists for storing the write messages, and the circular lists are used for storing the write messages, and how the slices store the write messages in the circular lists is described below:
for example, each slice includes a plurality of circular lists, each circular list includes n storage locations, for any circular list in each slice, if each storage location in the any circular list can store one write message, for any circular list, if n storage locations of the any circular list all have stored write messages, when it is determined that a new write message is to be stored in the any circular list, the new write message is, for the any circular list, an n +1 th write message of the any circular list, at this time, the new write message is written into a 1 st storage location of the any circular list, that is, a history write message stored at the 1 st storage location in the any circular list is overwritten, in summary, the storage manner of the circular list is that circular storage is performed from the 1 st storage location to a last storage location in the any circular list, and after the last storage location is occupied, the circular list is recycled to the storage manner in which the 1 st storage location starts to store.
Specifically, when writing a write message into a segment corresponding to a room identifier in the distributed system based on the room identifier of the virtual room, the following (1) to (3) may be included:
(1) Based on the room identification, a shard corresponding to the room identification is selected from the shards of the second type storage system.
Each segment in the second type storage system is identified with a number, for example, if the second type storage system includes 10 segments, the number may be denoted as segment 1, segment 2, \ 8230, segment 10, then based on the room identifier, a segment corresponding to the room identifier is selected from the segments in the second type storage system, and the segment mapped to the room identifier may be determined in a plurality of mapping manners.
For example, when the room identifier is composed of numbers, a preset number may be selected, and then the room identifier and the preset number are calculated through a setting algorithm to obtain a segment corresponding to the room identifier, where the setting algorithm is to divide the room identifier and the preset number, and a segment corresponding to a remainder is used as a segment corresponding to the room identifier, for example, the room identifier is 6556789, and the preset number is 10, and the remainder is 9, that is, the segment 9 is used as a segment corresponding to the room identifier.
(2) And selecting a target circular list corresponding to the room identifier and the user identifier in the selected slice corresponding to the room identifier based on the room identifier and the user identifier corresponding to the write message.
As mentioned above, each segment includes a plurality of recycle lists, where each recycle list may be uniquely identified by a user identifier and a room identifier, so that a target recycle list corresponding to the room identifier and the user identifier may be selected from the selected segments corresponding to the room identifier according to the room identifier and the user identifier corresponding to the write message.
(3) Write messages are written to the target circular list.
When the write message is stored in the target circular list, the current write position corresponding to the target circular list is also determined, where the current write position corresponding to the target circular list is determined in a similar manner to the determination of the current write position in the target storage queue, for example, the current write position corresponding to the target circular list may be determined according to the write time corresponding to each historical write message in the target circular list and the write time corresponding to the write message, for example, the current write position may be stored in a sequential manner, and if the latest historical write message is stored in the 8 th storage location of the target circular list, the current storage location corresponding to the target circular list may be the 9 th storage location of the slice.
In particular, when a write message is written into a target circular list, if a history storage message is already stored in a current storage position, the history write message stored in the current storage position is overwritten when the write message is written into the current storage position, and in addition, when the write message is written into the target circular list, in consideration of convenience in later extraction, a unique number is allocated to each newly written write message, for example, when the (n + 1) th write message is written into the 1 st storage position, the write message is identified by adopting the unique number n + 1.
The process of receiving the write-in message and writing the write-in message into the target storage system is described as follows, a message extraction process is described, after a user logs in a virtual live broadcast room, a point-to-point message can be extracted at regular time, and the process is described in detail as follows:
as shown in fig. 2, the message processing method provided in the embodiment of the present disclosure further includes the following specific steps S201 to S202:
s201, responding to a message extraction request sent by any receiving end, acquiring the current user number of the virtual room according to the room identifier of the virtual room contained in the message extraction request, and determining a target storage system corresponding to the message extraction request according to the current user number of the virtual room.
When the receiving end extracts the write-in message, the receiving end may send a message extraction request to the server, and according to the above-mentioned, when the write-in message is stored, the target storage system may be selected according to the current number of users of the virtual room corresponding to the receiving end, so that, when the write-in message is extracted, the current number of users of the virtual room corresponding to the receiving end that performs the message extraction may be determined first, and the target storage system in which the write-in message that the receiving end is to extract is stored may be determined.
S202, extracting the write-in message corresponding to the message extraction request from the target storage system corresponding to the message extraction request.
After the target storage system corresponding to the message extraction request is determined, the write message corresponding to the message extraction request can be extracted from the target storage system.
Specifically, corresponding to the above storage process of the write message, if the target storage system is the first type storage system, the write message is extracted from the target storage queue corresponding to the user identifier, the room identifier, and the device type identifier according to the user identifier, the room identifier, and the device type identifier included in the message extraction request.
Of course, if the target storage system is the second type storage system, it may be preferred to determine from which shard of the second type storage system the write message is to be extracted according to the room identifier, where the determining is the same as the above-mentioned manner for determining to which shard the write message is to be stored based on the room identifier, that is, for which target shard the write message of the receiving end is to be stored, here the write message to be extracted is searched from the target shard, for example, for which target shard the write message of the receiving end is to be stored in shard 10, here the write message to be extracted is searched from shard 10, and during specific extraction, a target circular list is found in the shard based on the user identifier and the room identifier corresponding to the write message, and then the write message is extracted from the target circular list.
In this way, after the server finds the write-in message corresponding to the message extraction request in the target storage system, the server can send the extracted write-in message to the receiving end for message extraction.
In addition, considering that a plurality of write messages matched with the receiving end exist in the target storage system, in order not to affect the message processing efficiency, the receiving end can extract the write messages in stages each time, namely, extract a set number of write messages each time, and in order to improve the message extraction efficiency, the receiving end can simultaneously send message extraction position information to the receiving end each time the extracted write messages are sent to the receiving end, so that the write messages to be searched can be quickly positioned when the write messages are extracted next time.
Specifically, in an embodiment, extracting a write message corresponding to the message extraction request from a target storage system corresponding to the message extraction request includes:
(1) Acquiring message extraction position information contained in the message extraction request;
(2) And according to the initial extraction position indicated by the information of the message extraction position, extracting the write-in message which corresponds to the message extraction request and is positioned behind the initial extraction position from the target storage system corresponding to the message extraction request.
For the first type of target storage system, because the target storage queue in the first type of target storage system stores write messages in a time sequence, that is, stores the write messages in a queue form, where the message extraction location information refers to a corresponding location of a last write message extracted last time in the queue, so that the initial extraction location indicated by the message extraction location information is a corresponding location of the last write message extracted last time in the queue, for example, if the last write message extracted last time is at a 5 th location in the queue, the write message is extracted this time from the 6 th location.
In particular, if the extracted write message is deleted after each time of extracting the write message, the message extraction location information here is always the head of the queue, that is, when the target storage system is the first type storage system, the target storage queue is found based on the user identifier, the room identifier, and the device type identifier included in the message extraction request, and then the write message is extracted from the head of the queue of the target storage queue.
In addition, for the second type storage system, because the fragments in the second type storage system store the write messages in a circular list form, each write message corresponds to a unique number, and the message extraction position information here may specifically be a number corresponding to the write message, and here, the initial extraction position may be determined according to a code corresponding to the write message.
For example, if the code corresponding to the last write message extracted last time is 005, the initial extraction position when performing write message extraction is the position indicated by number 005, specifically, during extraction, a specific segment may be found according to the room identifier included in the message extraction request, then a target circular list of the segment may be found according to the user identifier and the room identifier included in the message extraction request, and then the write message extraction is started after the initial extraction position, that is, the position indicated by number 005.
In addition, in order not to affect the message extraction efficiency when considering that the number of write messages corresponding to the message extraction request and located after the initial extraction position is large, the message extraction threshold may be preset, and specifically, when extracting a write message corresponding to a message extraction request and located after the initial extraction position from the target storage system corresponding to the message extraction request, the method may include:
and in the target storage system corresponding to the message extraction request, when the number of the write messages corresponding to the message extraction request and positioned behind the initial extraction position is determined to exceed a preset message extraction threshold, extracting the number of the write messages corresponding to the message extraction threshold from the write messages corresponding to the message extraction request and positioned behind the initial extraction position.
For example, the message extraction threshold here is 20, and if it is determined that the write messages corresponding to the message extraction request and located after the initial extraction position include 50 write messages, the first 20 write messages may be sequentially extracted from the 50 write messages here in order not to affect the message processing efficiency and the live broadcast effect of the live broadcast room.
For the above, the common first-type storage system is a Redis, and the Redis does not support storing the write message in a circular list form, so that as the write message increases, the storage space of the Redis gradually decreases, and the storage efficiency is greatly affected, therefore, the embodiment of the present disclosure provides that, when the target storage system is the first-type storage system, after the write message corresponding to the message extraction request is extracted from the target storage system corresponding to the message extraction request, the message processing method further includes:
in the target storage system, the extracted write message is deleted.
For example, after the write message is extracted from the target storage queue corresponding to key = ABC001: 6556789.
To sum up, for the first type storage system, when the same user logs in the live broadcast room through different types of terminal devices, because the same write-in message is stored in the target storage queue corresponding to each device type identifier, the same write-in message can be extracted from the target storage queue corresponding to each device type identifier at the same time, and thus, the effect that the user can receive the point-to-point message at the same time when different devices log in the same account of the live broadcast room is achieved.
In addition, considering that each fragment in the second type storage system stores the write messages in a circular list form, storage positions in the circular list contained in each fragment can be reused, so that the extracted write messages do not need to be deleted after the write messages in the fragment are extracted, and in addition, when the write messages are extracted from the circular list, the write messages can be obtained according to the numbers of the write messages, so that a user can be ensured not to pull repeated old data, the write messages do not need to be deleted, and therefore when the write messages are stored in the fragments, a plurality of devices are supported to pull the same point-to-point messages at the same time.
The following describes the message processing procedure with a specific embodiment in conjunction with fig. 3:
the server can comprise a message storage module and a message extraction module, wherein the message storage module judges whether the write-in message is to be sent to a hot live broadcast room or a common live broadcast room after receiving the write-in message, the number of the current users in the live broadcast room can be used for determining, when the write-in message is determined to be sent to the users in the hot live broadcast room, the write-in message can be stored into Redis, and specifically, when the write-in message is stored, the write-in message can be stored into a target storage queue corresponding to a user identifier, a room identifier and each device type identifier which correspond to the write-in message in Redis according to a preset device type identifier; when it is determined that the write message is sent to the user of the ordinary live broadcast room, the write message may be stored in a segment in the distributed storage system, and the segment may be specifically determined according to a room identifier of the ordinary live broadcast room.
When the message extraction module of the server extracts information for a message sent by a receiving end, corresponding extraction is performed according to a storage mode of a write-in message, for example, if the write-in message sent to the receiving end is stored in Redis, the write-in message is also extracted from Redis during extraction, and if the write-in message sent to the receiving end is stored in fragments, the write-in message is also extracted from the fragments during extraction.
In summary, when the write-in message is stored in the embodiment of the present disclosure, on one hand, it is considered that a receiving end to which the write-in message is to be sent is located in a hot live broadcast room or a common live broadcast room, so that the write-in message is stored according to different storage systems, thereby reducing dependence on Redis and ensuring service performance of Redis.
It will be understood by those of skill in the art that in the above method of the present embodiment, the order of writing the steps does not imply a strict order of execution and does not impose any limitations on the implementation, as the order of execution of the steps should be determined by their function and possibly inherent logic.
Based on the same technical concept, a message processing apparatus corresponding to the message processing method is also provided in the embodiments of the present disclosure, and since the principle of solving the problem of the apparatus in the embodiments of the present disclosure is similar to the message processing method in the embodiments of the present disclosure, the implementation of the apparatus may refer to the implementation of the method, and repeated parts are not described again.
Referring to fig. 4, a schematic diagram of a message processing apparatus 400 provided in an embodiment of the present disclosure is shown, where the message processing apparatus 400 includes: an acquisition module 401, a selection module 402 and a write module 403.
The obtaining module 401 is configured to obtain, when receiving the write-in message, information of a receiving end corresponding to the write-in message; the information of the receiving end comprises a user identifier of the receiving end and a room identifier of the virtual room corresponding to the written message;
a selecting module 402, configured to obtain the current number of users in the virtual room according to the room identifier, and select a target storage system according to the current number of users in the virtual room;
a writing module 403, configured to, when the selected target storage system is a first-type storage system, write a write message into a target storage queue corresponding to a user identifier, a room identifier, and a device type identifier in the first-type storage system, for each device type identifier that is preset; the first type of storage system is used for storing write messages of virtual rooms with the corresponding number of current users reaching a set number threshold.
In a possible implementation, before writing the write message into the corresponding target storage queue in the first type storage system together with the user identifier, the room identifier, and the device type identifier, the write module 403 is further configured to:
searching whether a target storage queue corresponding to a user identifier, a room identifier and each equipment type identifier exists in a first type storage system;
upon determining that a target storage queue does not exist, creating a target storage queue associated with a target identification, a room identification, and each device type identification corresponding to the write message in the first type storage system.
In one possible implementation, the writing module 403 is further configured to:
when the selected target storage system is a second type storage system, writing the write-in message into a segment corresponding to the room identifier in the second type storage system based on the room identifier of the virtual room; the second type storage system is used for storing write-in messages of virtual rooms, the number of corresponding current users of which does not reach a set number threshold value; each slice in the second type of storage system contains a plurality of circular lists for storing write messages, each circular list containing a plurality of storage locations for storing write messages.
In one possible implementation, the writing module 403, when configured to write the write message into the slice corresponding to the room identifier in the distributed system based on the room identifier of the virtual room, includes:
based on the room identifier, selecting a fragment corresponding to the room identifier from the fragments of the second type storage system;
selecting a target circular list corresponding to the room identifier and the user identifier from the selected fragments corresponding to the room identifier based on the room identifier and the user identifier corresponding to the write-in message;
write messages are written to the target circular list.
In a possible implementation, the message processing apparatus 400 further includes an extracting module 404, where the extracting module 404 is configured to:
responding to a message extraction request sent by any receiving terminal, acquiring the current user number of a virtual room according to the room identifier of the virtual room contained in the message extraction request, and determining a target storage system corresponding to the message extraction request according to the current user number of the virtual room;
and extracting the write-in message corresponding to the message extraction request from the target storage system corresponding to the message extraction request.
In one possible implementation, the extracting module 404, when configured to extract the write message corresponding to the message extraction request from the target storage system corresponding to the message extraction request, includes:
acquiring message extraction position information contained in the message extraction request;
and according to the initial extraction position indicated by the information of the message extraction position, extracting the write-in message which corresponds to the message extraction request and is positioned behind the initial extraction position from the target storage system corresponding to the message extraction request.
In one possible implementation, the extracting module 404, when configured to extract the write message corresponding to the message extraction request and located after the initial extraction position from the target storage system corresponding to the message extraction request, includes:
and in the target storage system corresponding to the message extraction request, when the number of the write messages corresponding to the message extraction request and positioned behind the initial extraction position is determined to exceed a preset message extraction threshold, extracting the number of the write messages corresponding to the message extraction threshold from the write messages corresponding to the message extraction request and positioned behind the initial extraction position.
In a possible implementation manner, the message processing apparatus 400 further includes a deleting module 405, where when the target storage system is the first type storage system, after the extracting module 404 extracts the write message corresponding to the message extraction request from the target storage system corresponding to the message extraction request, the deleting module 405 is configured to:
in the target storage system, the extracted write message is deleted.
The description of the processing flow of each module in the device and the interaction flow between the modules may refer to the related description in the above method embodiments, and will not be described in detail here.
Corresponding to the message processing method in fig. 1, an embodiment of the present disclosure further provides an electronic device 500, and as shown in fig. 5, a schematic structural diagram of the electronic device 500 provided in the embodiment of the present disclosure includes:
a processor 51, a memory 52, and a bus 53; the storage 52 is used for storing execution instructions and includes a memory 521 and an external storage 522; the memory 521 is also referred to as an internal memory, and is used for temporarily storing the operation data in the processor 51 and the data exchanged with the external memory 522 such as a hard disk, the processor 51 exchanges data with the external memory 522 through the memory 521, and when the electronic device 500 operates, the processor 51 communicates with the memory 52 through the bus 53, so that the processor 51 executes the following instructions: when receiving the write-in message, acquiring information of a receiving end corresponding to the write-in message; the information of the receiving end comprises a user identifier of the receiving end and a room identifier of the virtual room corresponding to the written message; acquiring the current user number of the virtual room according to the room identifier, and selecting a target storage system according to the current user number of the virtual room; when the selected target storage system is a first-type storage system, writing the write-in message into a corresponding target storage queue in the first-type storage system corresponding to the user identifier, the room identifier and the equipment type identifier aiming at each preset equipment type identifier; the first type of storage system is used for storing write messages of virtual rooms with the corresponding number of current users reaching a set number threshold.
The embodiments of the present disclosure also provide a computer-readable storage medium, on which a computer program is stored, where the computer program is executed by a processor to perform the steps of the message processing method described in the above method embodiments. The storage medium may be a volatile or non-volatile computer-readable storage medium.
The computer program product of the message processing method provided in the embodiments of the present disclosure includes a computer-readable storage medium storing a program code, where instructions included in the program code may be used to execute steps of the message processing method in the above method embodiments, which may be referred to specifically for the above method embodiments, and are not described herein again.
The embodiments of the present disclosure also provide a computer program, which when executed by a processor implements any one of the methods of the foregoing embodiments. The computer program product may be embodied in hardware, software or a combination thereof. In an alternative embodiment, the computer program product is embodied in a computer storage medium, and in another alternative embodiment, the computer program product is embodied in a Software product, such as a Software Development Kit (SDK), or the like.
It can be clearly understood by those skilled in the art that, for convenience and simplicity of description, the specific working process of the system and the apparatus described above may refer to the corresponding process in the foregoing method embodiment, and details are not described herein again. In the several embodiments provided in the present disclosure, it should be understood that the disclosed system, apparatus, and method may be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one logical division, and there may be other divisions when actually implemented, and for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed coupling or direct coupling or communication connection between each other may be through some communication interfaces, indirect coupling or communication connection between devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present disclosure may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a non-volatile computer-readable storage medium executable by a processor. Based on such understanding, the technical solutions of the present disclosure, which are essential or part of the technical solutions contributing to the prior art, may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the methods described in the embodiments of the present disclosure. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
Finally, it should be noted that: the above-mentioned embodiments are merely specific embodiments of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, but not to limit the technical solutions, and the scope of the present disclosure is not limited thereto, and although the present disclosure is described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: those skilled in the art can still make modifications or changes to the embodiments described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the technical scope of the disclosure; such modifications, changes or substitutions do not depart from the spirit and scope of the embodiments of the present disclosure, and should be construed as being included therein. Therefore, the protection scope of the present disclosure shall be subject to the protection scope of the claims.