Message publishing and query method, device, electronic device and computer medium
By distinguishing user types and selecting message queues, the information flow system is optimized by a combination of push and pull, which solves the performance problems of the information flow system during high concurrent access and improves the system performance.
Patent Information
- Application Number
- CN202310100085.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-02
- Publication Date
- 2024-11-08
- Estimated Expiration
- 2043-02-02
AI Technical Summary
The information flow system has performance problems during high concurrent access, and the push mode and pull mode have defects, resulting in delays in message push and query or excessive overhead.
By dividing users into ordinary users, ordinary public accounts and global public accounts, select different message queues when message is published according to user type for pushing, and obtain messages from the global message queue and ordinary message queue during query, using a combination of push and pull Optimize the information flow system in a way.
It effectively solves the problem of high concurrent access in the information flow system, improves system performance, and reduces the delay and overhead of message push and query.
Smart Images

Figure CN116132393B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a message publishing method, a message query method, a message publishing device, a message query device, an electronic device, and a computer-readable medium. Background Art
[0002] The core functions of social platforms are all based on the information flow (Feed) system, which provides subscription and distribution functions between information producers and consumers. For example, if user A follows users B, C, and D, the information content posted by users ABCD will be displayed on user A's timeline page in the order of posting time.
[0003] The implementation logic of the information flow system mainly includes push mode and pull mode. For the push mode, when a user has a large number of followers, the overhead of pushing messages is very high, there will be delays in pulling new messages, and data redundancy is very serious. For the pull mode, the query overhead is also high. Therefore, both modes have some performance issues.
[0004] In view of this, there is an urgent need in the art for a message publishing and query method that can solve the problem of high concurrent access to information flow systems and improve system performance.
[0005] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0006] The purpose of the present disclosure is to provide a message publishing method, a message query method, a message publishing device, a message query device, an electronic device and a computer-readable medium, thereby at least to a certain extent being able to solve the problem of high concurrent access to the information flow system and improve the performance of the system.
[0007] According to a first aspect of the present disclosure, a method for publishing a message is provided, comprising:
[0008] In response to a message publishing operation of a user, a user type of the user is acquired, wherein the user type includes a common user, a common public account, and a global public account;
[0009] The message content published by the user is stored in a database, a corresponding message identifier is obtained, and the message identifier is inserted into the message publishing cache of the user;
[0010] The message publishing time of the user is updated, and the message identifier is pushed to the corresponding message queue according to the user type.
[0011] According to a second aspect of the present disclosure, a message query method is provided, comprising:
[0012] In response to the user's message query instruction, the homepage global message is obtained from the global message queue cache according to the number of single-page messages, wherein the global message includes the message published by the global public account;
[0013] Determine whether the user's ordinary message queue cache exists. If the ordinary message queue cache exists, obtain the homepage ordinary messages from the ordinary message queue cache according to the number of single-page messages, wherein the ordinary messages include messages published by ordinary users followed by the user and ordinary public accounts;
[0014] If the common message queue cache does not exist, the common user list and common public account list followed by the user are pulled out through the user's attention cache, and common messages with a number of pages of messages are obtained according to the common user list and the common public account list respectively;
[0015] Cache the common messages of the plurality of pages of messages into the common message queue cache of the user, and obtain the common messages of the home page according to the common messages of the plurality of pages of messages;
[0016] The home page message to be returned by the user is obtained according to the number of single-page messages, the common home page message and the global home page message.
[0017] According to a third aspect of the present disclosure, a message publishing device is provided, including:
[0018] A user type acquisition module, configured to acquire the user type of the user in response to the user's message publishing operation, wherein the user type includes ordinary users, ordinary public accounts, and global public accounts;
[0019] A message identification acquisition module, used to store the message content published by the user in a database, obtain the corresponding message identification, and insert the message identification into the message publishing cache of the user;
[0020] The message queue push module is used to update the message publishing time of the user and push the message identifier to the corresponding message queue according to the user type.
[0021] According to a fourth aspect of the present disclosure, a message query device is provided, including:
[0022] A global message acquisition module, which is used to respond to a user's message query instruction and obtain the homepage global message from the global message queue cache according to the number of single-page messages, wherein the global message includes the message published by the global public account;
[0023] A first common message acquisition module, used to determine whether the common message queue cache of the user exists, and if so, to acquire the common messages on the homepage from the common message queue cache according to the number of messages on a single page, wherein the common messages include messages published by common users followed by the user and common public accounts;
[0024] A second common message acquisition module is used for, if the common message queue cache does not exist, pulling the common user list and the common public account list followed by the user through the user's attention cache, and respectively acquiring common messages of multiple pages of messages according to the common user list and the common public account list;
[0025] A multi-page common message cache module, used for caching the common messages of the multi-page message quantity into the common message queue cache of the user, and obtaining the common message of the home page according to the common messages of the multi-page message quantity;
[0026] The home page message returning module is used to obtain the home page message to be returned by the user according to the number of single-page messages, the home page common messages and the home page global messages.
[0027] According to a fifth aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute any one of the message publishing methods described above by executing the executable instructions.
[0028] According to a sixth aspect of the present disclosure, a computer-readable medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the method for publishing a message described in any one of the above is implemented.
[0029] The exemplary embodiments of the present disclosure may have the following beneficial effects:
[0030] In the message publishing and querying method of the example implementation method of the present disclosure, by dividing users into three types: ordinary users, ordinary public accounts, and global public accounts, when a message is published, the message identifier is pushed to different message queues according to different user types, and when a message is queried, the message to be returned is obtained from the global message queue cache and the ordinary message queue cache, respectively, wherein the global message queue cache includes global messages published by global public accounts, and the ordinary message queue cache includes ordinary users followed by users and ordinary messages published by ordinary public accounts. The message publishing and querying method of the example implementation method of the present disclosure selects different message pushing and pulling methods according to different user types, and according to business needs, the information flow system is changed to a combination of push and pull for implementation, wherein ordinary users are implemented in a "push and pull" manner, ordinary public accounts are implemented in a "pull" manner, and global public accounts are implemented in a "push" manner, which can solve the high concurrent access of the information flow system and improve the performance of the information flow system.
[0031] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification are used to explain the principles of the present disclosure. Obviously, the accompanying drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without creative work.
[0033] Figure 1 A schematic diagram showing a flow chart of a method for publishing a message according to an exemplary embodiment of the present disclosure;
[0034] Figure 2 A schematic diagram showing a process of pushing a message identifier to a message queue in an exemplary embodiment of the present disclosure;
[0035] Figure 3 A schematic diagram of a process of writing a message identifier into a common message queue cache according to an exemplary embodiment of the present disclosure is shown;
[0036] Figure 4 A schematic diagram showing a flow chart of a method for writing data into a global message queue cache according to an exemplary embodiment of the present disclosure;
[0037] Figure 5 A schematic flow chart of a method for reading data in a global message queue cache according to an exemplary embodiment of the present disclosure is shown;
[0038] Figure 6A complete flow chart of common user message push according to a specific implementation of the present disclosure is shown;
[0039] Figure 7 A complete flowchart of global public account message push according to a specific implementation of the present disclosure is shown;
[0040] Figure 8 A complete flowchart of common public account message push according to a specific implementation of the present disclosure is shown;
[0041] Fig. 9 A schematic diagram showing a flow chart of a message query method according to an exemplary embodiment of the present disclosure;
[0042] Fig.10 A schematic diagram showing a flow chart of obtaining the number of multi-page messages of a common message according to an exemplary embodiment of the present disclosure;
[0043] Fig.11 A schematic diagram showing a flow chart of a method for querying a continuation page message according to an exemplary embodiment of the present disclosure;
[0044] Fig.12 A schematic diagram showing a process of obtaining a continuation page common message according to an exemplary embodiment of the present disclosure;
[0045] Fig.13 A complete flow chart of home page message query according to a specific implementation of the present disclosure is shown;
[0046] Fig.14 A complete flow chart of a continuation page message query according to a specific implementation of the present disclosure is shown;
[0047] Fig.15 A block diagram showing a message publishing device according to an exemplary embodiment of the present disclosure;
[0048] Fig.16 A block diagram showing a message query device according to an exemplary embodiment of the present disclosure;
[0049] Fig.17 A schematic diagram of the structure of a computer system suitable for implementing the electronic device of the embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0050] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as being limited to the examples set forth herein; on the contrary, these embodiments are provided so that the present disclosure will be more comprehensive and complete, and the concepts of the example embodiments are fully conveyed to those skilled in the art. The described features, structures, or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure may be practiced while omitting one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known technical solutions are not shown or described in detail to avoid obscuring various aspects of the present disclosure.
[0051] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.
[0052] The performance optimization of information flow systems mainly requires solving two problems: business logic and data access.
[0053] At the business logic level, the information flow system has two main implementation logics:
[0054] 1. Push mode, that is, maintain a time-ordered message queue for each user. When a user publishes a message, the message ID is pushed to the message queue of each of his followers. Advantages of push mode: the overhead of pulling messages is very small; Disadvantages of push mode: when a user has a large number of followers, the overhead of pushing messages is very high, there will be a delay in pulling new messages, and a copy of the message ID must be stored in the queue of each follower, which is very redundant.
[0055] 2. Pull mode: There is only a message table with the author id field. The user's timeline messages are not persistently stored. When the user queries the timeline, the messages of all the users followed by the user are filtered out from the message table and the first X messages are returned in chronological order. Advantages of the pull mode: low message sending overhead, low storage space occupation, and low new message latency. Disadvantages of the pull mode: high query overhead.
[0056] Based on the above content, we can see that the push mode and the pull mode have their own applicable scenarios. It is necessary to flexibly select the appropriate mode and use them in combination according to the actual characteristics of the business.
[0057] At the data access level, the cache of the information flow system is usually implemented using a distributed cache system (such as RedisCluster). The distributed cache system has the advantages of high concurrency, convenient horizontal expansion, and high availability, but the configuration of a single cache node is relatively low. Conventional data storage methods will cause hot data problems. For example, globally unique data such as hot topic rankings and official post lists are usually saved in the RedisCluster cluster with a single key (key value). The data distribution scheme of the distributed cache system will distribute each key to a single node. The cluster will select a node in the cluster to store this key according to the preset allocation algorithm. When reading, all requests will be hit on this node. When the access frequency of one or some keys is very high, the node containing the hot key will be accessed frequently, which will cause the system load to increase. When the load exceeds the range, timeout errors and other problems will occur, while other nodes are idle, failing to take advantage of the distributed cache system and causing performance problems.
[0058] Based on the above problems, this example implementation first provides a method for publishing a message. Figure 1 As shown, the method for publishing the above message may include the following steps:
[0059] Step S110. In response to the user's message publishing operation, the user type of the user is obtained, where the user type includes ordinary users, ordinary public accounts, and global public accounts.
[0060] Step S120: Store the message content published by the user in the database, obtain the corresponding message identifier, and insert the message identifier into the user's message publishing cache.
[0061] Step S130: Update the user's message publishing time, and push the message identifier to the corresponding message queue according to the user type.
[0062] Next, combine Figures 2 to 5 The above steps of this exemplary embodiment are described in more detail.
[0063] In step S110, in response to the user's message publishing operation, the user type of the user is obtained, where the user type includes ordinary users, ordinary public accounts, and global public accounts.
[0064] In this example implementation, the user types can be divided into three types according to business needs: ordinary users, ordinary public accounts, and global public accounts. Among them, ordinary users refer to ordinary individual users, ordinary public accounts refer to public accounts that ordinary users can follow or unfollow at will, and global public accounts refer to public accounts that all users in the platform must follow, that is, public accounts that users cannot unfollow.
[0065] In step S120, the message content published by the user is stored in the database, the corresponding message identifier is obtained, and the message identifier is inserted into the user's message publishing cache.
[0066] The data table in the persistent storage database used in this example implementation is designed as follows:
[0067]
[0068] Among them, post_id (message identifier) can be in objectid format (24-bit hexadecimal string) or numeric format, and is sorted in ascending order by message release time.
[0069] In this example implementation, after the message content is saved in the database, the corresponding post_id can be obtained. After the post_id is obtained, it is inserted into the user's message publishing cache.
[0070] In step S130, the user's message publishing time is updated, and the message identifier is pushed to the corresponding message queue according to the user type.
[0071] The cache structure used in this example implementation is designed as follows:
[0072] First, a message queue A is maintained for each user, that is, a common message queue cache. You can use the sorted set of redis to save the common messages of all common users and common public accounts followed by the current user in reverse chronological order. For example, if there are X messages per page, the first 10*X common messages can be saved in the common message queue cache. This cache has an expiration time and is refreshed every time the timeline is queried.
[0073] Secondly, a separate message queue B is established for the global public accounts that users cannot unsubscribe from, namely the global message queue cache, which saves the messages published by all global public accounts in reverse chronological order. There is only one such cache, so no expiration time is set.
[0074] In addition, a cache is created for each user's list of ordinary users and ordinary public account users, and the redis set method can be used to improve the performance of pulling the follow list. This cache is updated in real time when the user follows / unfollows.
[0075] In this example implementation, after the corresponding message identifier is obtained, the user's message publishing time, ie, first_post_time and last_post_time in the user table, is updated, and then the message push is processed separately according to the user type.
[0076] In this example implementation, Figure 2 As shown, according to the user type, the message identifier is pushed to the corresponding message queue, which may specifically include the following steps:
[0077] Step S210: If the user type of the user is a common user, the message identifier is written into the common message queue buffer corresponding to the user's followers.
[0078] Among them, the general message queue cache is used to save a specified number of the latest messages published by all general users and general public accounts followed by the current user.
[0079] For ordinary users, after the message is saved successfully, an asynchronous task of pushing the message can be initiated.
[0080] In this example implementation, Figure 3 As shown, writing the message identifier into the common message queue cache corresponding to the user's followers may specifically include the following steps:
[0081] Step S310: Pull the user's follower list through the user's follow cache.
[0082] In the asynchronous task, first pull the uid list of all followers of the user through the follow cache.
[0083] Step S320: Filter out the followers in the follower list that do not exist in the common message queue cache in a pipeline manner, and write the message identifier into the common message queue cache corresponding to the other followers after the filter.
[0084] Use the exists (check whether the query returns data) command of redis to filter out followers who do not have the common message queue cache, and do not push messages to users who have not logged in for a long time and therefore have no message queue cache. Then use the zadd (element added to an ordered set) command of redis to insert the message identifier post_id into the common message queue cache of each follower, that is, message queue A. You can use pipeline (redis pipeline) to request to reduce the impact of network delay.
[0085] Step S220: If the user type of the user is a global public account, the message identifier is written into the global message queue cache.
[0086] For global public accounts, after the message is successfully saved, you can initiate a push message asynchronous task. In the asynchronous task, use the zadd command of redis to insert the message identifier post_id into the global message queue cache, that is, the special message queue B. Among them, the global message queue cache is used to save all messages published by global public accounts.
[0087] The message queue B here is globally unique. There may be a hot key problem during high-concurrency access. To solve this problem, for globally unique data caches like message queue B, the key format can be modified. For example, it can be changed from data_key to data_key:%s, where %s is the key number. This can be implemented in a variety of ways according to the format of the access user uid.
[0088] In this example implementation, Figure 4 As shown, the method for writing data into the global message queue cache may specifically include the following steps:
[0089] Step S410: Determine multiple target key values according to the user identifier of the user.
[0090] If the user ID of the user is in a string format, multiple target key values are determined according to the last character of the user ID.
[0091] Assuming that the user's uid is in objectid format (a 24-bit hexadecimal string), the target key number %s can be the last character of the user's uid, i.e. data_key:0~data_key:9~data_key:a~data_key:e, a total of 16 keys.
[0092] If the user ID of the user is in a numeric format, multiple target key values are determined based on the last digit of the user ID.
[0093] Assuming that the user's uid is in digital format, the target key value number %s can be the remainder obtained by dividing the uid by 10, that is, the last digit, data_key:0~data_key:9, a total of 10 keys.
[0094] Step S420: Write the data to be written into multiple target key values, and randomly distribute the target key values to multiple different cache nodes for storage.
[0095] After determining multiple target key values, when writing to the cache, you can use the pipeline mechanism to write the same data to these target key values at the same time. RedisCluster can relatively randomly assign these keys to different nodes for storage.
[0096] In this example implementation, Figure 5 As shown, the method for reading data in the global message queue cache may specifically include the following steps:
[0097] Step S510: If the user identification of the user is in a character string format, the corresponding key value number is obtained according to the last character of the user identification, and data is read from the target key value according to the key value number.
[0098] Step S520: If the user ID of the user is in digital format, the corresponding key value number is obtained according to the last digit of the user ID, and data is read from the target key value according to the key value number.
[0099] When reading the cache, you can select the corresponding key to read based on the uid of the accessing user. For example, if user A's uid is 5349b4ddd2781d08c09890fe, and the last character is e, this user reads the data corresponding to data_key:e. User B's uid is 5c1c3db7937b4f141c2301e2, and the last character is 2, this user reads the data corresponding to data_key:2. In this way, the load can be balanced to multiple nodes in the cluster, alleviating the problem of excessive load on a single node caused by hot keys.
[0100] Step S230: If the user type is a common public account, the message identifier is not pushed.
[0101] For ordinary public accounts, that is, public accounts that users can follow or unfollow at will, the publishing process is completed by saving the message content in the database, and the message identifier is not pushed.
[0102] In this example implementation, the hot data problem of the information flow system can be solved and the performance of the system can be further improved through reasonable operation procedures and scientific data storage formats.
[0103] like Figure 6 The figure shows a complete flow chart of ordinary user message push in a specific implementation mode of the present disclosure. The specific steps of the flow chart are as follows:
[0104] Step S610: Insert the message and obtain the message identifier.
[0105] Store the message content posted by the user in the database and obtain the corresponding message identifier.
[0106] Step S620: Insert the message identifier into the user's message publishing cache.
[0107] Step S630: Update the message publishing time.
[0108] Update first_post_time and last_post_time in the users table.
[0109] Step S640: Query the user's follower list.
[0110] Pull the list of all followers of the user through the follow cache.
[0111] Step S650: Insert the follower's timeline table.
[0112] Step S651: Filter out followers that do not exist in the common message queue cache.
[0113] Use the exists command of redis to filter out followers who do not have the normal message queue cache, and do not push messages to users who have not logged in for a long time and therefore have no message queue cache.
[0114] Step S652: Write the message identifier into the follower's common message queue buffer.
[0115] Use the redis zadd command to insert the message identifier post_id into the normal message queue cache of each follower.
[0116] Among them, step S651 and step S652 can be executed in the pipeline mode of redis.
[0117] like Figure 7 The figure shows a complete flow chart of global public account message push in a specific implementation of the present disclosure. The specific steps of the flow chart are as follows:
[0118] Step S710: Insert a message and obtain a message identifier.
[0119] Store the message content posted by the user in the database and obtain the corresponding message identifier.
[0120] Step S720: Insert the message identifier into the user's message publishing cache.
[0121] Step S730: Update the message publishing time.
[0122] Update first_post_time and last_post_time in the users table.
[0123] Step S740: Write the message identifier into the global message queue cache.
[0124] For global public accounts, after the message is successfully saved, you can initiate a push message asynchronous task. In the asynchronous task, use the zadd command of redis to insert the message identifier post_id into the global message queue cache.
[0125] like Figure 8 The figure shows a complete flow chart of ordinary public account message push in a specific implementation of the present disclosure. The specific steps of the flow chart are as follows:
[0126] Step S810: Insert the message and obtain the message identifier.
[0127] Step S820: Insert the message identifier into the user's message publishing cache.
[0128] Step S830: Update the message publishing time.
[0129] For ordinary public accounts, you can unsubscribe from the public account, save the message content in the database to complete the publishing process, and do not push the message ID.
[0130] This example implementation also provides a message query method. Fig. 9 As shown, the above message query method may include the following steps:
[0131] Step S910: In response to the user's message query instruction, obtain the homepage global message from the global message queue cache according to the number of single-page messages. The global message includes the message published by the global public account.
[0132] Step S920: Determine whether the user's ordinary message queue cache exists. If the ordinary message queue cache exists, obtain the homepage ordinary message from the ordinary message queue cache according to the number of single-page messages. Among them, ordinary messages include messages published by ordinary users followed by the user and ordinary public accounts.
[0133] Step S930. If the ordinary message queue cache does not exist, the ordinary user list and ordinary public account list followed by the user are pulled through the user's attention cache, and ordinary messages with multiple pages of messages are obtained according to the ordinary user list and the ordinary public account list.
[0134] Step S940: Cache the common messages of multiple message pages into the common message queue cache of the user, and obtain the common messages of the home page according to the common messages of multiple message pages.
[0135] Step S950. According to the number of single-page messages, as well as the homepage common messages and the homepage global messages, obtain the homepage message to be returned by the user.
[0136] Next, combine Figures 10 to 12 The above steps of this exemplary embodiment are described in more detail.
[0137] In step S910, in response to the user's message query instruction, the home page global message is obtained from the global message queue cache according to the number of single-page messages.
[0138] In this example implementation, when a user's message query instruction is received, the zrevrange (return members within a specified interval in an ordered set) command can be used to obtain the homepage global message from message queue B, i.e., the global message queue cache. Among them, the global message includes the message published by the global public account. Assuming that the number of messages on a single page is X, the first X messages published by the global public account that cannot be unfollowed are obtained as the homepage global message.
[0139] In step S920, it is determined whether the user's ordinary message queue cache exists. If the ordinary message queue cache exists, the homepage ordinary message is obtained from the ordinary message queue cache according to the number of single-page messages.
[0140] Determine whether message queue A, that is, the user's ordinary message queue cache, exists. If it does (cache hit), directly use the zrevrange command to obtain the homepage ordinary messages from the ordinary message queue cache. Assuming that the number of messages on a single page is X, obtain the first X ordinary messages as the homepage ordinary messages. Among them, ordinary messages include messages published by ordinary users followed by the user and ordinary public accounts.
[0141] In step S930, if the ordinary message queue cache does not exist, the ordinary user list and ordinary public account list followed by the user are pulled through the user's attention cache, and ordinary messages with multiple pages of messages are obtained according to the ordinary user list and the ordinary public account list.
[0142] If the ordinary message queue cache does not exist (cache miss), the ordinary user list and ordinary public account list followed by the current user are pulled through the user's follow cache, and ordinary messages with multiple pages of messages are obtained according to the ordinary user list and the ordinary public account list, which are used for the ordinary message queue cache and the return of the home page message.
[0143] In this example implementation, Fig.10 As shown, obtaining common messages with multiple pages of messages according to the common user list and the common public account list may include the following steps:
[0144] Step S1010. Obtain multiple pages of common messages according to the common user list.
[0145] First, obtain the common messages of multiple pages according to the common user list followed by the current user. Assuming that the number of single-page messages is X and the number of multi-page messages to be obtained is 10 pages, obtain the first 10*X common messages according to the common user list.
[0146] Step S1020. Filter the ordinary public accounts in the ordinary public account list according to the posting time of the ordinary public accounts in the ordinary public account list.
[0147] According to the post_id list of the global message on the homepage obtained in step S910, the earliest time t1 and the latest time t2 of the post_id list are obtained, and then from the list of ordinary public accounts, ordinary public accounts whose first release time is not empty and whose latest release time is ≥ t1 are filtered out, and ordinary public accounts whose message release time does not meet expectations are filtered out. This screening can significantly reduce the query overhead of the message table in the next step.
[0148] Step S1030. According to the filtered list of ordinary public accounts, obtain multiple pages of ordinary messages from the user's message publishing cache.
[0149] According to the filtered list of common public accounts, the number of multiple pages of messages is obtained from the user's message publishing cache, for example, 10 pages, that is, the first 10*X common messages.
[0150] In step S940, common messages of multiple message pages are cached in the common message queue cache of the user, and the common messages on the home page are obtained according to the common messages of multiple message pages.
[0151] The first 10*X ordinary messages obtained from the message publishing cache are cached in the user's ordinary message queue cache, and a timeout is set, for example, a 5-minute timeout. If the user initiates a query or flips back within 5 minutes, the cache hit process will be followed. At the same time, the first X ordinary messages of these 10*X ordinary messages are used as the homepage ordinary messages.
[0152] In step S950, the home page message to be returned by the user is obtained according to the number of single-page messages, as well as the home page common messages and the home page global messages.
[0153] Finally, the homepage common messages and the homepage global messages can be merged and sorted according to their message identifiers to obtain the homepage messages of the number of single-page messages to be returned by the user. For example, the first X homepage common messages and the first X homepage global messages can be merged and sorted to obtain the first X homepage messages to be returned.
[0154] In this example implementation, the interface function is to return messages posted by all users followed by the current user, in reverse order of posting time, and return one page each time, for example, X messages. The interface requirement is to return in reverse order of posting time, so in the returned message list, the return order of post_id should be in descending order.
[0155] In addition, refer to Fig.11 As shown, a message query method provided by this example implementation may also include the following steps:
[0156] Step S1110. In response to the user's page turning query instruction, the last message identifier in the home page message is used as the starting message identifier of the second page.
[0157] When the user turns pages of messages, the starting message identifier since_id of the second page is set to the post_id of the last message on the previous page. Since post_id is in ascending order by publishing time, all post_ids on the current page will be smaller than the last post_id on the previous page.
[0158] Step S1120: Obtain, from the global message queue buffer according to the number of single-page messages, the continuation-page global messages whose message identifiers are greater than the start message identifier.
[0159] In this example implementation, the zrevrangebyscore (return all members within a specified score range in an ordered set) command can be used to obtain a page of messages greater than since_id from message queue B, i.e., the global message queue cache, as continuation page global messages. Assuming that the number of single-page messages is X, the first X messages greater than since_id are obtained as continuation page global messages.
[0160] Step S1130: Determine whether the user's common message queue cache exists. If the common message queue cache exists, obtain the continuation page common message whose message ID is greater than the start message ID from the common message queue cache according to the number of single-page messages.
[0161] If the common message queue cache exists (cache hit), use the zrevrangebyscore command to directly obtain a page of messages greater than since_id from the common message queue cache as continuation page common messages. Assuming the number of single-page messages is X, obtain the first X messages greater than since_id as continuation page common messages.
[0162] Because multiple pages of ordinary messages have been cached in the ordinary message queue cache in advance when obtaining the home page message, as long as the number of request pages issued by the client during continuous query does not exceed the number of cached pages, the user will hit the cache when turning pages for query.
[0163] Step S1140. If the ordinary message queue cache does not exist, the ordinary user list and ordinary public account list followed by the user are pulled through the user's attention cache, and the continuation page ordinary messages whose message identifiers are greater than the starting message identifier are obtained respectively according to the ordinary user list and the ordinary public account list.
[0164] If the ordinary message queue cache does not exist (cache miss), for example, the user does not access subsequent content for a long time after accessing the first page, causing the cache to expire, or accesses messages beyond the number of cached pages, the list of ordinary users and ordinary public accounts followed by the user is pulled through the user's follow cache, and the continuation page ordinary messages whose message identifiers are greater than the start message identifier are obtained respectively based on the ordinary user list and the ordinary public account list.
[0165] In this example implementation, Fig.12 As shown, obtaining the continuation page ordinary messages whose message identifiers are greater than the start message identifier according to the ordinary user list and the ordinary public account list respectively may include the following steps:
[0166] Step S1210: Obtain, according to the common user list, a continuation page common message whose message ID is greater than the start message ID.
[0167] First, according to the list of ordinary users followed by the current user, obtain the ordinary messages of the continuation page whose message ID is greater than the start message ID. Assuming that the number of messages on a single page is X, then the first X messages greater than the start message ID since_id.
[0168] Step S1220. Filter the ordinary public accounts in the ordinary public account list according to their posting time.
[0169] According to the post_id list of the global message on the continuation page obtained in step S1120, the latest publishing time t2 of the post_id is obtained, and then from the list of ordinary public accounts, ordinary public accounts with the first publishing time ≤ t2 and the latest publishing time not empty are screened out, and ordinary public accounts with message publishing time that does not meet expectations are filtered out. This screening can significantly reduce the query overhead of the message table in the next step.
[0170] Step S1230. According to the filtered list of ordinary public accounts, obtain the continuation page ordinary message whose message ID is greater than the start message ID from the user's message publishing cache.
[0171] According to the filtered list of ordinary public accounts, the continuation page ordinary messages whose message ID is greater than the starting message ID since_id are returned in reverse order in the message table of the database.
[0172] Step S1150. Obtain the continuation page message to be returned by the user according to the number of single-page messages, as well as the continuation page common message and the continuation page global message.
[0173] Finally, the continuation page common messages and the continuation page global messages can be merged and sorted according to the message identifiers to obtain the continuation page messages of the number of single-page messages to be returned by the user. For example, the first X messages obtained from the global message queue cache that are greater than the starting message identifier since_id and the first X messages of each common public account that are greater than the starting message identifier since_id obtained through the message publishing cache can be merged and sorted to obtain the first X continuation page messages to be returned.
[0174] like Fig.13 The figure is a complete flow chart of home page message query in a specific implementation mode of the present disclosure, which is a flowchart of the present example implementation mode. Fig. 9 The specific steps of the flowchart are as follows:
[0175] Step S1310: Query the global message queue cache to obtain the first X messages.
[0176] Use the zrevrange command to obtain the first X messages published by the global public accounts that cannot be unfollowed from message queue B.
[0177] Step S1320: Determine whether a common message queue cache exists.
[0178] If it exists, go to step S1330; if it does not exist, go to step S1340.
[0179] Step S1330: Query the common message queue cache to obtain the first X messages.
[0180] If it exists (cache hit), then use the zrevrange command to get the first X messages.
[0181] Merge and sort the two post_id lists obtained in the first two steps according to the publishing time and return the first X messages (post_id is in ObjectId format, and the publishing time field can be directly obtained without additional query). In this scenario, two redis operations are required to obtain the post_id list.
[0182] Step S1340: Query the common user list to obtain the first 10*X messages of the common users followed by the user.
[0183] If message queue A does not exist (cache miss), obtain the list of common user IDs followed by the user, and obtain the first 10*X messages of the common users followed by the user.
[0184] Step S1350: Query the follow cache to obtain a list of common public accounts followed by the user.
[0185] Obtain a list of public account IDs that the user follows through the follow cache.
[0186] Step S1360. Filter out ordinary public accounts that do not meet the requirements based on posting time.
[0187] If the post_id list is obtained in step S1310, the earliest time t1 and the latest time t2 of the post_id list are obtained. By obtaining users whose first publishing time is not empty and the latest publishing time ≥ t1 in the user table, ordinary public accounts whose message publishing time does not meet expectations are filtered out. This screening can significantly reduce the query overhead of the message table in the next step.
[0188] Step S1370. Obtain the first 10*X messages of each ordinary public account through the message publishing cache.
[0189] By returning the latest 10*X post_ids in the message table of the database in reverse order according to the condition of posting time ≥ t1, the query obtains the first 10*X messages of ordinary users followed by the user and the first 10*X messages of ordinary public accounts, and then merges and sorts the first 10*X ordinary messages.
[0190] Step S1380: Cache the result in the general message queue cache and set a timeout.
[0191] The post_ids of the 10*X common messages in step S1370 are added to the message queue A, and a timeout is set. For example, a timeout of 5 minutes is set. If the user initiates a query again within 5 minutes or turns back no more than 10 pages, the cache hit process will be followed.
[0192] Finally, the first X ordinary messages are obtained from the 10*X ordinary messages, and merged and sorted with the first X messages obtained from the global message queue cache to obtain the first X homepage messages to be returned.
[0193] like Fig.14 The figure is a complete flow chart of the continuation page message query in a specific implementation mode of the present disclosure, which is a flowchart of the continuation page message query in this example implementation mode. Fig.11 The specific steps of the flowchart are as follows:
[0194] Step S1410: Query the global message queue cache to obtain the first X messages with a value greater than the start message identifier.
[0195] When turning pages, set the starting message identifier since_id = the last message id (post_id) of the previous page. Since post_id is in ascending order by release time, all post_ids of the current page will be smaller than the last post_id of the previous page. Then use the zrevrangebyscore command to obtain X global public account messages greater than since_id from message queue B.
[0196] Step S1420: Determine whether a common message queue cache exists.
[0197] If it exists, go to step S1430; if it does not exist, go to step S1440.
[0198] Step S1430: Query the common message queue cache to obtain the first X messages with a value greater than the start message identifier.
[0199] If the cache exists (cache hit), use the zrevrangebyscore command to obtain X messages greater than since_id. Since 10*X ordinary message data have been cached in step S1380, as long as the number of request pages issued by the client during continuous query is not greater than 10, the cache will be hit. Considering that the probability of a user turning pages more than 10 times in a row is low, the cache hit rate will be relatively high (the 10 pages here is an empirical value. If the number X per page is small, the user is more likely to turn to the later pages, and the number of cached pages can be increased). Then merge and sort the two post_id lists obtained in the first two steps according to the release time and return the first X.
[0200] Step S1440: Query the common user list to obtain the first X messages greater than the start message identifier from common users followed by the user.
[0201] If the cache misses (for example, the user does not visit the first page for a long time, visits the second page after the cache expires, or visits messages more than 10 pages later), the common user list is queried to obtain the first X messages greater than the start message identifier of the common users followed by the user.
[0202] Step S1450: Query the follow cache to obtain a list of common public accounts followed by the user.
[0203] Obtain a list of public account IDs that the user follows through the follow cache.
[0204] Step S1460. Filter out ordinary public accounts that do not meet the requirements based on posting time.
[0205] Get the latest publishing time t2 of the X post_ids in step S1410, and filter out the users whose message publishing time does not meet expectations by obtaining the users whose first publishing time ≤ t2 and whose latest publishing time is not empty in the user table. This screening can significantly reduce the query overhead of the next message table.
[0206] Step S1470. Obtain the first X messages of each common public account that are greater than the start message identifier through the message publishing cache.
[0207] By following the filtered list of common public accounts in the message table of the database, X messages with a publishing time ≤ the current earliest time t1 are returned in reverse order.
[0208] Finally, the first X messages greater than the start message identifier obtained from the global message queue cache and the first X messages greater than the start message identifier of each ordinary public account obtained through the message publishing cache are merged and sorted to obtain the first X continuation page messages to be returned.
[0209] Through the message publishing and query method in this example implementation, the QPS (Query Per Second) of the information flow query interface is doubled compared to before optimization, while the hardware resources remain unchanged. The peak value of the additional cache space occupancy is increased by 30% compared to before optimization, which is within an acceptable range.
[0210] It should be noted that although the steps of the method in the present disclosure are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.
[0211] Furthermore, the present disclosure also provides a message publishing device. Fig.15 As shown, the message publishing device may include a user type acquisition module 1510, a message identifier acquisition module 1520, and a message queue push module 1530. Among them:
[0212] The user type acquisition module 1510 may be used to acquire the user type of the user in response to the user's message publishing operation, wherein the user type includes a common user, a common public account, and a global public account;
[0213] The message identifier acquisition module 1520 may be used to store the message content published by the user into a database, obtain the corresponding message identifier, and insert the message identifier into the user's message publishing cache;
[0214] The message queue push module 1530 can be used to update the user's message publishing time and push the message identifier to the corresponding message queue according to the user type.
[0215] In some exemplary embodiments of the present disclosure, the message queue push module 1530 may include a common user message push unit, a global public account message push unit, and a common public account message push unit.
[0216] The common user message push unit can be used to write the message identifier into the common message queue cache corresponding to the user's followers if the user type of the user is a common user, wherein the common message queue cache is used to save a specified number of latest messages published by all common users and common public accounts followed by the current user;
[0217] The global public account message push unit can be used to write the message identifier into the global message queue cache if the user type of the user is a global public account, wherein the global message queue cache is used to store all messages published by the global public account;
[0218] The common public account message push unit can be used to not push the message identifier if the user type of the user is a common public account.
[0219] In some exemplary embodiments of the present disclosure, the common user message push unit may include a follower list pulling unit and a follower list screening unit.
[0220] The follower list pulling unit may be used to pull the user's follower list through the user's follow cache;
[0221] The follower list screening unit can be used to screen out followers in the follower list that do not exist in the common message queue cache in a pipeline manner, and write the message identifier into the common message queue cache corresponding to other filtered followers.
[0222] In some exemplary embodiments of the present disclosure, the global public account message push unit may include a target key value determination unit and a data writing unit.
[0223] The target key value determination unit may be used to determine a plurality of target key values according to a user identifier of a user;
[0224] The data writing unit can be used to write the data to be written into multiple target key values, and randomly distribute the target key values to multiple different cache nodes for storage.
[0225] In some exemplary embodiments of the present disclosure, the target key value determination unit may include a string target key value determination unit and a number target key value determination unit.
[0226] The character string target key value determination unit may be used to determine multiple target key values according to the last character of the user identification if the user identification of the user is in a character string format;
[0227] The digital target key value determination unit may be configured to determine a plurality of target key values according to the last digit of the user identification if the user identification of the user is in a digital format.
[0228] In some exemplary embodiments of the present disclosure, the global public account message push unit may further include a string data reading unit and a digital data reading unit.
[0229] The string data reading unit can be used to obtain the corresponding key value number according to the last character of the user identification if the user identification is in a string format, and read data from the target key value according to the key value number;
[0230] The digital data reading unit can be used to obtain a corresponding key value number according to the last digit of the user identification if the user identification is in digital format, and read data from the target key value according to the key value number.
[0231] Furthermore, the present disclosure also provides a message query device. Fig.16 As shown, the message query device may include a global message acquisition module 1610, a first common message acquisition module 1620, a second common message acquisition module 1630, a multi-page common message cache module 1640, and a homepage message return module 1650. Among them:
[0232] The global message acquisition module 1610 can be used to respond to the user's message query instruction and obtain the homepage global message from the global message queue cache according to the number of single-page messages, wherein the global message includes the message published by the global public account;
[0233] The first common message acquisition module 1620 can be used to determine whether the common message queue cache of the user exists. If the common message queue cache exists, the common messages on the home page are acquired from the common message queue cache according to the number of single-page messages, wherein the common messages include messages published by common users followed by the user and common public accounts;
[0234] The second common message acquisition module 1630 may be used to pull the common user list and common public account list followed by the user through the user's attention cache if the common message queue cache does not exist, and obtain common messages of multiple pages of messages according to the common user list and the common public account list respectively;
[0235] The multi-page common message buffer module 1640 can be used to buffer common messages of the number of multi-page messages into the common message queue buffer of the user, and obtain the homepage common messages according to the number of common messages of the number of multi-page messages;
[0236] The home page message returning module 1650 can be used to obtain the home page message to be returned by the user according to the number of single-page messages, as well as the home page common messages and the home page global messages.
[0237] In some exemplary embodiments of the present disclosure, the second general message acquisition module 1630 may include a general user message acquisition unit, a general public account filtering unit, and a general public account message acquisition unit.
[0238] The common user message acquisition unit may be used to acquire common messages of a plurality of pages according to the common user list;
[0239] The ordinary public account filtering unit may be used to filter the ordinary public accounts in the ordinary public account list according to the posting time of the ordinary public accounts in the ordinary public account list;
[0240] The common public account message acquisition unit can be used to acquire common messages of multiple pages from the user's message publishing cache according to the filtered common public account list.
[0241] In some exemplary embodiments of the present disclosure, the home page message return module 1650 may include a home page message merging and sorting unit, which can be used to merge and sort the home page common messages and the home page global messages according to their message identifiers to obtain the home page messages with the number of single-page messages to be returned by the user.
[0242] In some exemplary embodiments of the present disclosure, a message query device provided by the present disclosure may further include a start message identifier determination module, a continuation page global message acquisition module, a first continuation page common message acquisition module, a second continuation page common message acquisition module, and a continuation page message return module. Wherein:
[0243] The starting message identifier determination module may be used to respond to a page turning query instruction from a user and use the last message identifier in the home page message as the starting message identifier of the second page;
[0244] The continuation page global message acquisition module can be used to obtain the continuation page global message whose message identifier is greater than the start message identifier from the global message queue cache according to the number of single-page messages;
[0245] The first continuation page common message acquisition module can be used to determine whether the user's common message queue cache exists, and if the common message queue cache exists, obtain the continuation page common message whose message identifier is greater than the start message identifier from the common message queue cache according to the number of single-page messages;
[0246] The second continuation page common message acquisition module can be used to pull the common user list and common public account list followed by the user through the user's attention cache if the common message queue cache does not exist, and obtain the continuation page common messages whose message identifiers are greater than the start message identifier according to the common user list and the common public account list respectively;
[0247] The continuation page message return module can be used to obtain the continuation page message to be returned by the user according to the number of single-page messages, as well as the continuation page common message and the continuation page global message.
[0248] In some exemplary embodiments of the present disclosure, the second continuation page general message acquisition module may include a continuation page general user message acquisition unit, a continuation page general public account message filtering unit, and a continuation page general public account message acquisition unit.
[0249] The continuation page common user message acquisition unit may be used to acquire the continuation page common message whose message identifier is greater than the start message identifier according to the common user list;
[0250] The ordinary public account message filtering unit can be used to filter the ordinary public accounts in the ordinary public account list according to the posting time of the ordinary public accounts in the ordinary public account list;
[0251] The continuation page ordinary public account message acquisition unit can be used to acquire the continuation page ordinary message whose message identifier is greater than the start message identifier from the user's message publishing cache according to the filtered ordinary public account list.
[0252] In some exemplary embodiments of the present disclosure, the continuation page message return module may include a continuation page message merging and sorting unit, which can be used to merge and sort the continuation page ordinary messages and the continuation page global messages according to their message identifiers to obtain the continuation page messages of the number of single-page messages to be returned by the user.
[0253] The specific details of each module / unit in the above-mentioned message publishing device and message query device have been described in detail in the corresponding method embodiment part, and will not be repeated here.
[0254] Fig.17 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present invention is shown.
[0255] It should be noted that Fig.17 The computer system 1700 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0256] like Fig.17As shown, the computer system 1700 includes a central processing unit (CPU) 1701, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 1702 or the program loaded from the storage part 1708 to the random access memory (RAM) 1703. In the RAM 1703, various programs and data required for system operation are also stored. The CPU 1701, the ROM 1702, and the RAM 1703 are connected to each other through a bus 1704. An input / output (I / O) interface 1705 is also connected to the bus 1704.
[0257] The following components are connected to the I / O interface 1705: an input section 1706 including a keyboard, a mouse, etc.; an output section 1707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1708 including a hard disk, etc.; and a communication section 1709 including a network interface card such as a LAN card, a modem, etc. The communication section 1709 performs communication processing via a network such as the Internet. A drive 1710 is also connected to the I / O interface 1705 as needed. A removable medium 1711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1710 as needed, so that a computer program read therefrom is installed into the storage section 1708 as needed.
[0258] In particular, according to an embodiment of the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present invention includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication section 1709, and / or installed from a removable medium 1711. When the computer program is executed by a central processing unit (CPU) 1701, various functions defined in the system of the present application are executed.
[0259] It should be noted that the computer-readable medium shown in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0260] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0261] As another aspect, the present application also provides a computer-readable medium, which may be included in the electronic device described in the above embodiment; or may exist independently without being assembled into the electronic device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by an electronic device, the electronic device implements the method described in the above embodiment.
[0262] It should be noted that, although several modules of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules described above can be concretized in one module. Conversely, the features and functions of one module described above can be further divided into multiple modules to be concretized.
[0263] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any modifications, uses or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not disclosed in the present disclosure.
[0264] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A method for publishing a message, characterized in that: include: In response to a message publishing operation of a user, a user type of the user is acquired, wherein the user type includes an ordinary user, an ordinary public account, and a global public account; The message content published by the user is stored in a database, a corresponding message identifier is obtained, and the message identifier is inserted into the message publishing cache of the user; Update the message publishing time of the user, and push the message identifier to the corresponding message queue according to the user type; Among them, pushing the message identifier to the corresponding message queue according to the user type includes: if the user type of the user is the ordinary user, writing the message identifier into the ordinary message queue cache corresponding to the user's followers, and the ordinary message queue cache is used to save a specified number of latest messages published by all the ordinary users and ordinary public accounts followed by the current user; if the user type of the user is the global public account, writing the message identifier into the global message queue cache, and the global message queue cache is used to save all messages published by the global public account; if the user type of the user is the ordinary public account, the message identifier is not pushed.
2. The method for publishing a message according to claim 1, characterized in that: The step of writing the message identifier into a common message queue buffer corresponding to the followers of the user includes: Pulling the follower list of the user through the follower cache of the user; The followers in the follower list that do not exist in the common message queue cache are filtered out in a pipeline manner, and the message identifier is written into the common message queue cache corresponding to other followers after the screening.
3. The method for publishing a message according to claim 1, characterized in that: The method for writing data into the global message queue cache comprises: Determining a plurality of target key values according to a user identifier of the user; The data to be written is written into the multiple target key values, and the target key values are randomly distributed to multiple different cache nodes for storage.
4. The method for publishing a message according to claim 3, characterized in that: The determining of a plurality of target key values according to the user identifier of the user comprises: If the user ID of the user is in a string format, determining multiple target key values according to the last character of the user ID; If the user identification of the user is in digital format, multiple target key values are determined according to the last digit of the user identification.
5. The method for publishing a message according to claim 4, characterized in that: The method for reading data in the global message queue cache includes: If the user ID of the user is in a string format, a corresponding key value number is obtained according to the last character of the user ID, and data is read from the target key value according to the key value number; If the user identification of the user is in digital format, the corresponding key value number is obtained according to the last digit of the user identification, and data is read from the target key value according to the key value number.
6. A message query method, characterized in that: include: In response to the user's message query instruction, the homepage global message is obtained from the global message queue cache according to the number of single-page messages, wherein the global message includes the message published by the global public account; Determine whether the user's ordinary message queue cache exists. If the ordinary message queue cache exists, obtain the homepage ordinary messages from the ordinary message queue cache according to the number of single-page messages, wherein the ordinary messages include messages published by ordinary users followed by the user and ordinary public accounts; If the common message queue cache does not exist, the common user list and common public account list followed by the user are pulled out through the user's attention cache, and common messages with a number of pages of messages are obtained according to the common user list and the common public account list respectively; Cache the common messages of the plurality of pages of messages into the common message queue cache of the user, and obtain the common messages of the home page according to the common messages of the plurality of pages of messages; The home page message to be returned by the user is obtained according to the number of single-page messages, the common home page message and the global home page message.
7. The message query method according to claim 6, characterized in that: The obtaining of a plurality of pages of ordinary messages according to the ordinary user list and the ordinary public account list includes: Acquire multiple pages of common messages according to the common user list; Filtering the ordinary public accounts in the ordinary public account list according to the posting time of the ordinary public accounts in the ordinary public account list; According to the filtered list of ordinary public accounts, multiple pages of ordinary messages are obtained from the message publishing cache of the user.
8. The message query method according to claim 6, characterized in that: The obtaining the home page message to be returned by the user according to the number of single-page messages, the home page common messages and the home page global messages includes: The home page common messages and the home page global messages are merged and sorted according to their message identifiers to obtain home page messages corresponding to the number of single-page messages to be returned by the user.
9. The message query method according to claim 6, characterized in that: The method further comprises: In response to a page turning query instruction from a user, taking the last message identifier in the home page message as the start message identifier of the second page; According to the number of single-page messages, obtaining from the global message queue buffer a continuation-page global message whose message identifier is greater than the start message identifier; Determine whether the user's common message queue cache exists, and if so, obtain, from the common message queue cache, a continuation page common message whose message identifier is greater than the start message identifier, according to the number of single-page messages; If the common message queue cache does not exist, then pull the common user list and common public account list followed by the user through the user's attention cache, and obtain the continuation page common message whose message identifier is greater than the start message identifier according to the common user list and the common public account list respectively; The continuation page message to be returned by the user is obtained according to the number of the single-page messages, the continuation page common message and the continuation page global message.
10. The message query method according to claim 9, characterized in that: The obtaining, according to the ordinary user list and the ordinary public account list, respectively, the continuation page ordinary message whose message identifier is greater than the start message identifier, comprises: Acquire, according to the common user list, a continuation page common message whose message identifier is greater than the start message identifier; Filtering the ordinary public accounts in the ordinary public account list according to the posting time of the ordinary public accounts in the ordinary public account list; According to the filtered list of common public accounts, a continuation page common message whose message identifier is greater than the start message identifier is obtained from the message publishing cache of the user.
11. The message query method according to claim 9, characterized in that: The obtaining of the continuation page message to be returned by the user according to the number of the single-page messages, the continuation page common message and the continuation page global message comprises: The continuation page common messages and the continuation page global messages are merged and sorted according to their message identifiers to obtain continuation page messages corresponding to the number of single-page messages to be returned by the user.
12. A message publishing device, characterized in that: include: A user type acquisition module, configured to acquire the user type of the user in response to the user's message publishing operation, wherein the user type includes ordinary users, ordinary public accounts, and global public accounts; A message identification acquisition module, used to store the message content published by the user in a database, obtain the corresponding message identification, and insert the message identification into the message publishing cache of the user; A message queue push module, used to update the message publishing time of the user and push the message identifier to the corresponding message queue according to the user type; Among them, pushing the message identifier to the corresponding message queue according to the user type includes: if the user type of the user is the ordinary user, writing the message identifier into the ordinary message queue cache corresponding to the user's followers, and the ordinary message queue cache is used to save a specified number of latest messages published by all the ordinary users and ordinary public accounts followed by the current user; if the user type of the user is the global public account, writing the message identifier into the global message queue cache, and the global message queue cache is used to save all messages published by the global public account; if the user type of the user is the ordinary public account, the message identifier is not pushed.
13. A message query device, characterized in that: include: A global message acquisition module, which is used to respond to a user's message query instruction and obtain the homepage global message from the global message queue cache according to the number of single-page messages, wherein the global message includes the message published by the global public account; A first common message acquisition module, used to determine whether the common message queue cache of the user exists, and if so, to acquire the common messages on the homepage from the common message queue cache according to the number of messages on a single page, wherein the common messages include messages published by common users followed by the user and common public accounts; A second common message acquisition module is used for, if the common message queue cache does not exist, pulling the common user list and the common public account list followed by the user through the user's attention cache, and respectively acquiring common messages of multiple pages of messages according to the common user list and the common public account list; A multi-page common message cache module, used for caching the common messages of the multi-page message quantity into the common message queue cache of the user, and obtaining the common message of the home page according to the common messages of the multi-page message quantity; The home page message returning module is used to obtain the home page message to be returned by the user according to the number of single-page messages, the home page common messages and the home page global messages.
14. An electronic device, characterized in that: include: processor; as well as A memory for storing one or more programs, which, when executed by the processor, enables the processor to implement the message publishing method described in any one of claims 1 to 5, or the message query method described in any one of claims 6 to 11.
15. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method for publishing a message according to any one of claims 1 to 5 or the method for querying a message according to any one of claims 6 to 11 is implemented.
