Message pushing method and device

By using ordered sets and atomic commands in Redis to manage the number of message pushes, the problem that traditional frequency limiting methods are easily broken through thresholds when high concurrency is solved, achieving more accurate and reliable message push frequency limiting, and improving user experience.

CN119420804APending Publication Date: 2025-02-11SHANGHAI BILIBILI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411719780.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-27
Publication Date
2025-02-11

AI Technical Summary

Technical Problem

The traditional message push frequency limiting method is prone to break through the frequency limit threshold during high concurrent operations, causing the number of messages received by users to exceed expectations and affect the user experience.

Method used

By using ordered sets and atomic commands (such as ZINCRBY and INCR) in Redis, determine whether to push messages based on preset thresholds, and ensure the accuracy of frequency limiting.

Benefits of technology

It effectively avoids breaking through the frequency limit threshold under high concurrency, improves the accuracy and reliability of message push frequency limit, and improves the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119420804A_ABST
    Figure CN119420804A_ABST
Patent Text Reader

Abstract

Embodiments of the invention provide a message pushing method and apparatus. The method comprises the steps of obtaining a to-be-pushed message for a target object; determining a target type of the to-be-pushed message, wherein the target type comprises a long-term message type or a one-time message type; according to a target atomic command associated with the target type, obtaining the number of pushing times of messages belonging to the target type; and determining whether to push the to-be-pushed message to the target object or not according to the pushing times. According to the technical scheme provided by the embodiment of the invention, the command with the atomicity characteristic can be utilized to limit the frequency of the message push, so that the condition of breaking through the frequency limit during high concurrency is avoided, and the frequency limit accuracy is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of Internet technology, and in particular, to a message push method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Art

[0002] With the popularization of personal mobile terminal devices, it is becoming more and more common for users to receive information through mobile terminals such as mobile phones and tablets. Various applications or messaging systems will push notifications, reminders and other messages to users' personal mobile terminals through instant messaging, text messages, emails, etc. to inform users.

[0003] However, if too many messages are pushed to the user's personal mobile terminal, it will interfere with the user and the user experience will be poor. Therefore, in order to consider the user experience, it is necessary to limit the frequency of notifications, reminders and other messages received by the user. The traditional frequency limiting method has the following problems: the frequency limit threshold will be exceeded during high concurrency operations. For example, the limit is that a user receives 2 messages per week. The user has received 1 message in the previous week and can only receive 1 message at most now. However, if 10 notifications are sent to this user at the same time, when querying the maintained data table, it is found that the user has only received 1 message, so all of them can be sent. As a result, the user received a total of 11 messages, which is completely inconsistent with expectations. In the context of increasingly precise client frequency limiting requirements, if the traditional frequency limiting method is still used, it is very likely that the frequency limit will be exceeded during high concurrency and the demand cannot be met.

[0004] It should be noted that the above content is not necessarily prior art, nor is it intended to limit the scope of patent protection of this application. Summary of the invention

[0005] The embodiments of the present application provide a message push method, apparatus, computer device, computer-readable storage medium, and computer program product to solve or alleviate one or more of the technical problems raised above.

[0006] One aspect of an embodiment of the present application provides a message push method, the method comprising: Get the message to be pushed to the target object; Determine a target type of the message to be pushed, where the target type includes a long-term message type or a one-time message type; According to the target atomic command associated with the target type, obtaining the number of pushes of messages belonging to the target type; According to the number of pushes, it is determined whether to push the message to be pushed to the target object.

[0007] Optionally, the target type is the long-term message type, the long-term message type is associated with the first atomic command in the target atomic command, and the first atomic command is used for pushing times statistics of the ordered set; Correspondingly, according to the target atomic command associated with the target type, the number of pushes of messages belonging to the target type is obtained, including: Obtain an ordered set corresponding to the target object; Determine, according to the ordered set, a first push count of the message belonging to the long-term message type by using the first atomic command; Wherein, when the first push number is less than a first preset threshold, the message to be pushed is pushed to the target object.

[0008] Optionally, determining, according to the ordered set, by using the first atomic command, a first push count of the message belonging to the long-term message type includes: According to the preset window granularity and statistical rules, determine the current time window and the statistical time window in the ordered set; Determine the number of pushes in the current time window through the first atomic command; Obtain the number of pushes in the statistical time window; The number of pushes in the current time window and the number of pushes in the statistical time window are summed to obtain the first number of pushes.

[0009] Optionally, the message push method further includes: When the first number of pushes is greater than a first preset threshold, the message to be pushed is intercepted, and the number of pushes in the current time window is corrected.

[0010] Optionally, the message push method further includes: According to a preset rule, determining an expiration time window in the ordered set; Clear the expiration time window and the corresponding number of pushes.

[0011] Optionally, the target type is the one-time message type, the one-time message type is associated with a second atomic command in the target atomic command, the second atomic command is used to count the number of pushes for a key-value pair, and the value of the key-value pair is the number of pushes; Correspondingly, according to the target atomic command associated with the target type, the number of pushes of messages belonging to the target type is obtained, including: Obtaining a second push count of the message belonging to the one-time message type through the second atomic command and the preset first key-value pair; When the second push count is less than a second preset threshold, obtaining a third push count of the message for the target object and belonging to the one-time message type by using the second atomic command and a preset second key-value pair; Wherein, when the third number of pushes is less than a third preset threshold, the message to be pushed is pushed to the target object.

[0012] Optionally, the message push method further includes: When the second push number is greater than the second preset threshold, intercepting the message to be pushed and correcting the value of the first key-value pair; or When the third number of pushes is greater than the third preset threshold, the message to be pushed is intercepted and the value of the second key-value pair is corrected.

[0013] Another aspect of an embodiment of the present application provides a message push device, the device comprising: A first acquisition module is used to acquire a message to be pushed to a target object; A first determination module is used to determine the target type of the message to be pushed, where the target type includes a long-term message type or a one-time message type; A second acquisition module, configured to acquire the number of pushes of messages belonging to the target type according to a target atomic command associated with the target type; The second determination module is used to determine whether to push the message to be pushed to the target object according to the number of push times.

[0014] Another aspect of an embodiment of the present application provides a computer device, including: at least one processor; and a memory communicatively coupled to the at least one processor; Wherein: the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the message pushing method as described above.

[0015] Another aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and when the computer instructions are executed by a processor, the message push method described above is implemented.

[0016] Another aspect of an embodiment of the present application provides a computer program product, including a computer program, which implements the message push method described above when executed by a processor.

[0017] The above technical solution adopted in the embodiment of the present application may have the following advantages: Obtain the message to be pushed for the target object and determine the target type (long-term message type or one-time message type) of the message to be pushed. Determine the associated target atomic command according to the target type, so as to obtain the number of pushes of the message belonging to the target type through the target atomic command, and determine whether to push the message to be pushed to the target object according to the number of pushes. It can be seen that the embodiment of the present application can use commands with atomic characteristics to limit the frequency of message pushes to avoid breaking the frequency limit at high concurrency and improve the accuracy of the frequency limit. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The accompanying drawings exemplarily illustrate the embodiments and constitute a part of the specification, and together with the text description of the specification, are used to explain the exemplary implementation of the embodiments. The embodiments shown are for illustrative purposes only and do not limit the scope of the claims. In all drawings, the same reference numerals refer to similar but not necessarily identical elements.

[0019] Figure 1 The following schematically shows an operating environment diagram of the message push method according to the first embodiment of the present application; Figure 2 A flowchart of a message push method according to Embodiment 1 of the present application is schematically shown; Figure 3 A flowchart of pushing a long-term message according to the first embodiment of the present application is schematically shown; Figure 4 A flowchart of pushing a one-time message according to Embodiment 1 of the present application is schematically shown; Figure 5 A block diagram schematically shows a message push device according to Embodiment 2 of the present application; and Figure 6 The hardware architecture diagram of the computer device according to the third embodiment of the present application is schematically shown. DETAILED DESCRIPTION

[0020] In order to make the purpose, technical solutions and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.

[0021] It should be noted that the descriptions involving "first", "second", etc. in the embodiments of the present application are only for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by this application.

[0022] In the description of the present application, it should be understood that the numerical labels before the steps do not indicate the order in which the steps are executed, but are only used to facilitate the description of the present application and to distinguish each step, and therefore should not be understood as a limitation on the present application.

[0023] First, the following terms are explained: High concurrency: A user or many users operate at the same time, and the computer needs to process many requests at the same time.

[0024] Frequency limiting: restricting certain behaviors of a certain user or multiple users, such as limiting the sending of messages.

[0025] Secondly, in order to facilitate those skilled in the art to understand the technical solutions provided in the embodiments of the present application, the relevant technologies are described below: At present, various applications or messaging systems push notifications, reminders and other messages to users' personal mobile terminals through instant messaging, text messages, emails, etc. to inform users. However, if too many messages are pushed to users' personal mobile terminals, it will interfere with users and cause poor user experience. Therefore, in order to consider user experience, it is necessary to limit the frequency of notifications, reminders and other messages received by users.

[0026] However, the applicant has learned that the traditional frequency limiting method still has the following problems: the frequency limiting threshold will be exceeded during high-concurrency operations. For example, the limit is that a user receives 2 messages per week. The user has received 1 message in the previous week, and can only receive 1 message at most now. However, if 10 notifications are sent to this user at the same time, when querying the maintained data table, it is found that the user has only received 1 message, so all can be sent, resulting in the final result that the user received a total of 11 messages, which is completely inconsistent with expectations. In the context of increasingly precise client frequency limiting requirements, if the traditional frequency limiting method is still used, it is very likely that the frequency limit will be exceeded during high concurrency and the demand cannot be met.

[0027] To this end, the embodiment of the present application provides a technical solution for message push. In this technical solution, a complete message push frequency limiting solution is provided for messages of different target types. For long-term message types: by maintaining an ordered set for storing push data for each target object (such as a target user), the ZINCRBY command in Redis can be used to determine the number of pushes in the ordered set within the current time window, and use this as a basis to determine whether the frequency limiting condition is met. The message will be pushed to the target object only when the frequency limiting condition is not required. Because even if there are many messages that need to be sent to the target object at the same time, they are executed one by one on Redis, and the ZINCRBY command is increased or decreased, and there will be a return value after the operation. Therefore, in the scenario where a large number of messages are concurrently sent at the same time, even if they are executed at the same time, when parsing the results, the results obtained by ZINCRBY are gradually increasing. In theory, the second message will directly exceed the threshold, and it can be directly intercepted, thereby avoiding the situation of breaking the frequency limit at high concurrency and improving the effect of pushing message frequency limiting. For one-time message types: maintain two key-value pairs (such as the first key-value pair and the second key-value pair). The first key-value pair can be used to count the total number of pushes of messages belonging to the one-time message type (the second number of pushes), and the second key-value pair can be used to count the number of personal pushes of messages for the target object and belonging to the one-time message type (the third number of pushes). The INCR command similar to the ZINCRBY command in Redis can be used to determine the second and third pushes, and based on the second and third pushes, determine whether to push or intercept the message to be pushed. That is, the atomicity and uniqueness of Redis commands are used to solve high concurrency problems and achieve effective message push frequency limiting. See below for details.

[0028] Finally, for ease of understanding, an exemplary operating environment is provided below.

[0029] like Figure 1 As shown, the environment diagram includes a service platform 2, a network 4, and a client 6, wherein: The service platform 2 may be composed of a single or multiple computing devices. The multiple computing devices may include virtualized computing instances. Virtualized computing instances may include virtual machines, such as simulations of computer systems, operating systems, servers, etc. The computing device may load a virtual machine based on a virtual image and / or other data defining specific software (e.g., operating system, dedicated application, server) for simulation. As the demand for different types of processing services changes, different virtual machines may be loaded and / or terminated on one or more computing devices. A hypervisor may be implemented to manage the use of different virtual machines on the same computing device.

[0030] The service platform 2 may be configured to communicate with the client 6 or the like via a network 4. The network 4 includes various network devices, such as routers, switches, multiplexers, hubs, modems, bridges, repeaters, firewalls, proxy devices, and / or the like. The network 4 may include physical links, such as coaxial cable links, twisted pair cable links, optical fiber links, combinations thereof, and the like, or wireless links, such as cellular links, satellite links, Wi-Fi links, and the like.

[0031] The service platform 2 can provide storage, reading, writing, querying, deleting and other services, such as providing message push services for clients.

[0032] The client 6 may be an electronic device running an operating system such as Windows, Android™ or iOS, such as a smart phone, a tablet device, a laptop computer, a virtual reality device, a gaming device, a set-top box, a vehicle terminal, or a smart TV. Based on the above operating system, various applications such as message push can be run.

[0033] The client 6 may provide / configure a user access page for manipulating the service platform 2 or uploading an object, etc.

[0034] It should be noted that the above devices are exemplary, and the number and type of devices are adjustable in different scenarios or according to different needs.

[0035] The following uses the service platform 2 as the execution subject to introduce the technical solution of the present application through multiple embodiments. It should be noted that these embodiments can be implemented in a variety of different forms and should not be interpreted as being limited to the embodiments described here.

[0036] Embodiment 1 Figure 2 The flowchart of the message push method according to the first embodiment of the present application is schematically shown.

[0037] like Figure 2 As shown, the message push method may include steps S200 to S206, wherein: Step S200 , get the message to be pushed for the target object.

[0038] The target object is the object that receives the message, which can be a single user, a user group including multiple users, or other entities, such as a specific session, a subscribed channel, etc.

[0039] The message to be pushed includes the content that needs to be sent to the target object, and the content may include text, pictures, videos, audio, etc.

[0040] Step S202: determining the target type of the message to be pushed, wherein the target type includes a long-term message type or a one-time message type.

[0041] Exemplarily, the pushed messages may be of two types: a long-term message type (long-term notification) and a one-time message type (one-time notification).

[0042] Among them, the characteristics of long-term notifications are: this type of notification will be sent continuously, requiring each target object to only receive N notifications within a period of time, and this time and N can be adjusted at will.

[0043] The characteristics of a one-time notification are: the total upper limit for sending this type of notification is A, the time upper limit is B, and only one notification can be sent to each target object.

[0044] The embodiment of the present application can use Redis to count the number of message pushes. Redis (RemoteDictionary Server) is an open source, in-memory data structure storage system that can be used as a database, cache, and message middleware. The single-threaded feature of Redis is used to provide corresponding frequency limiting solutions for different types of messages.

[0045] Step S204: acquiring the number of pushes of messages belonging to the target type according to the target atomic command associated with the target type.

[0046] Exemplarily, when the target type is a long-term message type, an ordered set can be maintained in real time for the target object through an associated target atomic command (such as a first atomic command) to accurately count the number of pushes of messages belonging to the long-term message type. When the target type is a one-time message type, two key-value pairs can also be maintained in real time through an associated target atomic command (such as a second atomic command) to accurately count the number of pushes of messages belonging to the one-time message type. Several exemplary schemes will be provided below.

[0047] In an optional embodiment, the target type is a long-term message type, and the long-term message type is associated with the first atomic command in the target atomic command (such as a ZINCRBY command). Among them, the ZINCRBY command can be used in Redis to increase or decrease the score of a specified member member in an ordered set (Sorted Set). In practical applications, an ordered set (Sorted Set, also known as Zset) can be maintained for each target object (such as each user). In Redis, Zset is a string set that does not allow duplicate members, and each member member is associated with a score. Redis uses the score to sort the members in the set from small to large. In the embodiment of the present application, key can be used to identify the name of Zset, which is equivalent to the identifier of the ordered set. At the same time, member is creatively used to represent the time window, and score represents the number of pushes, rather than the timestamp. After this setting, the ordered set can be used to count the number of message pushes within a period of time. The ZINCRBY command can be used to update the ordered set.

[0048] Exemplarily, step S204 may include: Step S300, obtaining an ordered set corresponding to the target object.

[0049] Step S302: Determine the first push count of the message belonging to the long-term message type through the first atomic command according to the ordered set, wherein when the first push count is less than a first preset threshold, the message to be pushed is pushed to the target object.

[0050] Exemplarily, an ordered set of a target object may be obtained. An ordered set may include multiple members, each of which has a corresponding score. A member may represent a time window, such as one second, one hour, one day, or one week. Then, the value of the score corresponding to a member may represent the number of pushes of a long-term message type within one second, one hour, one day, or one week. Multiple members may be arranged according to the order in which they are inserted into the ordered set, such as member 1 corresponds to the first day, member corresponds to the second day, and so on, and member n corresponds to the nth day. Based on the ordered set, the first push count of a message belonging to a long-term message type may be determined by the ZINCRBY command. For example, if there is currently one message to be pushed, the ZINCRBY command may be used to record the message to be pushed into the ordered set, that is, the number of recommendations originally counted in the ordered set is increased by 1. The advantage of the ZINCRBY command is that even if there are multiple messages waiting to be sent to the target object at the same time, they are executed one by one on Redis. During the execution of the ZINCRBY command, no other commands can be inserted or interfered, and there will be a return value after the operation (the latest number of recommendations) to help determine whether the message push frequency needs to be limited. When the first push number is less than a first preset threshold (which can be set by yourself), the message to be pushed can be pushed to the target object.

[0051] In this embodiment, the Zset and ZINCRBY commands in Redis are used to effectively limit the frequency of messages belonging to the long-term message type, thereby solving the high concurrency problem.

[0052] In an optional embodiment, step S302 may include: Step S400, determining a current time window and a statistical time window in the ordered set according to preset window granularity and statistical rules.

[0053] Step S402: Determine the number of pushes in the current time window through the first atomic command.

[0054] Step S404, obtaining the number of pushes in the statistical time window.

[0055] Step S406: sum the number of pushes in the current time window and the number of pushes in the statistical time window to obtain the first number of pushes.

[0056] For example, the window granularity can be pre-set according to actual business needs and available storage resources. The window granularity will directly affect the number of members. The current time window (current member) can be determined based on the window granularity. For example, if the window granularity is seconds, the current time window is the current second; if the window granularity is hours, the current time window is the current hour; if the window granularity is half a day, the current time window is the current half day; if the window granularity is days, the current time window is the current day.

[0057] The statistical time window can be determined according to the statistical duration set by the specific business. For example, if a business needs to intercept a certain number of items in a recent period of time, this recent period of time is the statistical time window. The statistical time window can include one or more members. These members are inserted into the ordered set earlier than the current member.

[0058] The number of recommendations for the current time window (current member) can be determined by the ZINCRBY command. The number of recommendations for the statistical time window can be determined by the Zscore command. The Zscore command is used to obtain the score of a specified member in an ordered set in Redis. Each time it is determined whether the target object needs to limit the frequency of message push, the ZINCRBY command is first executed on the current time window of the ordered set to obtain the number of recommendations for the current time window, and then the score values ​​of all window members in a recent period of time are counted, that is, the number of recommendations for the statistical time window. The first number of recommendations can be obtained by summing the number of recommendations for the current time window and the number of recommendations for the statistical time window. When the first number of recommendations is less than (or equal to) the first preset threshold, the message to be pushed can be sent to the terminal device of the target object. The first preset threshold is used to indicate the maximum number of push messages, such as 2 or 5, which can be dynamically set according to actual needs.

[0059] In this embodiment, the number of recommendations in the current time window and the number of recommendations in the statistical time window are summed to obtain a first number of recommendations, and then it is determined whether the first number of recommendations exceeds a first preset threshold. If the first number of recommendations is less than or equal to the preset threshold, it means that there is no need to limit the frequency of the message to be pushed, and the message to be pushed can be sent to the terminal device of the target object. If it exceeds, it means that the current message to be pushed cannot be sent, and in order to ensure the frequency limiting effect, the message to be pushed can be intercepted.

[0060] In an optional embodiment, the message push method further includes: when the first push number is greater than a first preset threshold, intercepting the message to be pushed, and correcting the push number in the current time window.

[0061] Exemplarily, when the total amount of the target message is greater than the preset threshold, it means that the current message to be pushed cannot be sent, and the message to be pushed can be intercepted. Because the ZINCRBY command was previously executed to record the message to be pushed into the ordered set, but in fact the message to be pushed was not pushed to the target object. Therefore, it is necessary to correct the number of recommendations (score value) corresponding to the current time window (current member). For example, after intercepting the message to be pushed, the ZINCRBY command can be used to reduce the number of recommendations in the current time window by 1 to clean up the data, otherwise it is equivalent to counting this message, resulting in inaccurate statistical results. In some embodiments, when sending the message to be pushed to the target object, the message sending may fail due to network interruption, server overload, etc. At this time, the ZINCRBY command can also be used to reduce the number of recommendations in the current time window by 1 to clean up the data.

[0062] In an optional embodiment, an expiration time may be pre-set for the ordered set. For example, since the statistical time window is a recent period of time (such as 7 days), a 7-day expiration time may be set for Zset each time it is written, so that if there is no notification for a period of time, the data will be automatically cleared to avoid wasting space. It can be seen that this embodiment can effectively clear expired data and save storage costs.

[0063] However, it is possible that a user sends messages every day, and the user's member may be infinitely long, which is unreasonable, so the old member data needs to be cleaned up. The members of the window before the actual statistical time period (such as 7 days) are useless, because the statistics only count the past 7 days, but now the value of Zset is the number of times sent, not the timestamp, and has no time meaning. ZREMRANGEBYSCORE cannot be used to directly clean up the data. It is necessary to delete one by one according to the member value, so only a limited number of members can be deleted. Among them, the ZREMRANGEBYSCORE command is used in Redis to remove members (members) within a specified score range from an ordered set.

[0064] To alleviate the above problems, an exemplary solution is provided below.

[0065] In an optional embodiment, the message push method may further include: Step S500: determining an expiration time window in the ordered set according to a preset rule.

[0066] Step S502, clearing the expiration time window and the corresponding number of pushes.

[0067] For example, the expiration time window can be determined according to specific business needs and available storage resources, that is, which members and corresponding scores need to be cleared to reduce resource usage. The expiration time window (member) and the corresponding push count (score) are cleared through the ZREM command. The ZREM command is used to remove one or more members from an ordered set.

[0068] For example, the expiration time window can be set according to the statistical time window, for example: expiration time window = 2×statistical time window - 1×statistical time window. For example, if the statistical time window is 7 (members), then the expiration time window is 14-7 days (also 7 members).

[0069] By proposing to delete the data of the previous 14-7 days, this is because the data of the last 7 days is needed, and the data before 14 days will not exist, because there is no data before 7 days, and if there is a write from 8 to 14 days, then the data from 14 to 7 will be deleted, and there will be no data for 14 days. If there is no write from 8 to 14, by the 15th day, due to a long period of no write, Zset has automatically expired and no data exists. Therefore, using this method, it can be ensured that the members in Zset are always limited, which can greatly save costs.

[0070] The above embodiments exemplarily introduce the frequency limiting scheme corresponding to the long-term message type. The following will exemplarily introduce the frequency limiting scheme corresponding to the one-time message type.

[0071] In an optional embodiment, the target type is a one-time message type, and the one-time message type is associated with a second atomic command (such as an INCR command) in the target atomic command. The second atomic command (INCR command) can be used to count the number of pushes for a key-value pair, and has atomicity. The value of the key-value pair can be the number of pushes.

[0072] Correspondingly, step S204 may include: Step S500: Obtain a second push count of the message belonging to the one-time message type through the second atomic command and the preset first key-value pair.

[0073] Step S502, when the second push count is less than the second preset threshold, obtain the third push count of the message for the target object and belonging to the one-time message type through the second atomic command and the preset second key-value pair. Wherein, when the third push count is less than the third preset threshold, the message to be pushed is pushed to the target object.

[0074] Exemplarily, a first key-value pair and a second key-value pair may be pre-set in Redis. Among them, the value in the first key-value pair may be used to record the second recommendation number (equivalent to the total recommendation number) of a message belonging to a one-time message type. The value in the second key-value pair may be used to record the third recommendation number (i.e., the personal recommendation number) of a message for a target object and belonging to a one-time message type. First, the second recommendation number may be determined from the first key-value pair through an INCR command. When the second recommendation number is less than a second preset threshold (system message number threshold), the third recommendation number may be determined from the second key-value pair through an INCR command. When the third recommendation number is less than a third preset threshold (personal message number threshold), the message to be pushed may be sent to the terminal device of the target object.

[0075] In this embodiment, the atomicity of INCR and DECR commands similar to ZINCRBY commands in Redis is fully utilized to avoid the problem of frequency limit being exceeded.

[0076] In some embodiments, a cache can be built while setting the second key-value pair. If the target object has exceeded the number of receptions, it can directly enter the cache, which can reduce the cost of Redis. Here, the uniqueness of Redis commands is mainly used to solve the problems caused by high concurrency.

[0077] In an optional embodiment, the message recommendation method may further include: Step S600: When the second push number is greater than the second preset threshold, intercept the message to be pushed and correct the value of the first key-value pair. Step S602: When the third number of pushes is greater than the third preset threshold, intercept the message to be pushed and correct the value of the second key-value pair.

[0078] When the total amount of sent messages (the second recommended number of times) is greater than the system message quantity threshold (the second preset threshold), the message to be pushed can be intercepted. Since the INCR command was previously executed to record the message to be pushed into the first key-value pair, but the message to be pushed was not actually pushed to the target object, the DECR command can be used to clear the system sent data, that is, to correct the value of the first key-value pair (such as minus 1).

[0079] In this embodiment, when the total amount of the sent messages is greater than the system message quantity threshold, there is no need to execute the subsequent steps to generate messages. Therefore, if the sending fails, the DECR command can be used to clear the invalid sending to ensure that the data is clean. When the number of messages sent to the target object (the third recommended number of times) is greater than the personal message quantity threshold (the third preset threshold), the DECR command can be used to clear the system sent data and personal received data, that is, correct the value in the second key-value pair (such as minus 1) to ensure that the data is clean.

[0080] To further explain the message push method of this embodiment, Figure 3 A flowchart of pushing a long-term message is shown, specifically: Solution 1 (limiting the frequency of long-term messages): Each user can maintain an ordered list Zset, where member is the window granularity and value is the score of the message received in the window. The window granularity will directly affect the number of members.

[0081] The current frequency limit requirement is that n messages are received in the past 7 days, and the statistical time window is 7 days. If the fine-grainedness is 1 day, then at least 7 days of members will be maintained, but there will be a problem. The fine-grainedness is 1 day. When you take 7 days forward in the morning and evening of one day, you take 7 days in the morning and nearly 8 days in the evening, which may be an average of 7.5 days. It is impossible to achieve such a detailed level of seconds as the traditional method. However, you can approach it by continuously reducing the fine-grainedness. The cost is that the member value will increase and the storage cost will increase. You can make a choice freely according to the actual situation.

[0082] Each time we determine whether a user meets the frequency limit, we first execute the ZINCRBY command for the user's current time window, then count the score values ​​of all window members in the past 7 days and sum them up to determine whether they exceed the threshold. If they do, it means that the current message cannot be sent and we need to execute the ZINCRBY minus 1 command for the current window. Otherwise, it is equivalent to sending it on the same day.

[0083] At the same time, since the statistical time window is 7 days, you can also set a 7-day expiration time for Zset every time you write, so that if there is no notification for a period of time, the data will be automatically cleared to avoid wasting space. However, it may be sent to users every day, and the user's member may be infinitely long, which is unreasonable, so you need to clean up the old member data. In fact, the members of the window before 7 days are useless, because the statistics only count the past 7 days, but now the value of zset is the number of times it is sent, not the timestamp, and has no time meaning. You cannot use ZREMRANGEBYSCORE to clean up the data directly, and you need to delete them one by one according to the member value, so you can only delete a limited number of members.

[0084] Therefore, this embodiment proposes to delete the data of the previous 14-7 days (equivalent to 2× statistical window - 1× statistical window), because the data of the last 7 days is needed, and the data before 14 days will not exist, because there is no data before 7 days, and if there is data written from 8 to 14 days, then the data from 14 to 7 will be deleted, and there will be no data for 14 days, and if there is no data written from 8 to 14, by the 15th day, due to long-term non-writing, Zset has automatically expired and no data exists. Therefore, using this method, it can be ensured that the members in Zset are always limited, which can greatly save costs.

[0085] Supplementary explanation of specific terms: a) Statistical time window: Based on the business, for example, if the business needs to intercept more than a certain number of messages in a recent period of time, this number is the statistical time window.

[0086] b) Statistical granularity: This is equivalent to the statistical time error. For example, statistics can be counted by seconds, hours, half a day, or day. The finer the granularity, the smaller the statistical window error, and the corresponding cost will be higher.

[0087] c) Current Window: The current fine-grained computing window. Second is the current second, hour is the current hour, half day is the current half day, and day is the current day.

[0088] d) Statistical window: All windows divided by fine granularity within the statistical time window. Assuming that the fine granularity is set to half a day, there are 2×7=14 windows in the past 7 days. If the fine granularity is set to hourly, there are 24×7=84 windows in the past 7 days.

[0089] e) Expiration window: 2×statistical window - 1×statistical window. For example, if the statistical time window is 7, then it is 14-7 days.

[0090] Solution 2 (limiting the frequency of one-time messages): like Figure 4A flowchart of pushing a one-time message is shown. Specifically: In order to distinguish long-term messages, the characteristics of one-time messages are that there is a system total upper limit and a time upper limit, and each user can only send one message, and there is no need to maintain a time window. Make full use of the atomicity of the INCR and DECR commands similar to the ZINCRBY command in Redis to avoid the problem of frequency limit being exceeded.

[0091] The total number maintains a KV, and the value is the total number of notifications sent. If it exceeds the limit, it will be rejected. Each person maintains a KV, and the value indicates the number of times the user accepts. At the same time, a cache is built. If the user has already accepted it, it can directly enter the cache, which can reduce the cost of Redis. Here, the uniqueness of Redis commands is mainly used to solve the problem caused by high concurrency. Start sending, first use the INCR command to check whether the total number has exceeded: a) If it exceeds, a mark is needed (directly indicating that this notification category has exceeded, and there is no need to enter the subsequent push logic). At the same time, since it has exceeded, the sending has failed, and the DECR command needs to be used to clear this invalid sending to ensure clean data.

[0092] b) If it has not exceeded, use the INCR command to determine whether the individual has exceeded the limit. If not, the sending is allowed. If the sending fails, the DECR command must be used to clean up the individual and total data.

[0093] c) If it exceeds the limit, write it into the cache and delete the KV to save costs.

[0094] Embodiment 2 Figure 5 The block diagram of the message push device according to the second embodiment of the present application is schematically shown. The device can be divided into one or more program modules, one or more program modules are stored in a storage medium, and are executed by one or more processors to complete the embodiment of the present application. The program module referred to in the embodiment of the present application refers to a series of computer program instruction segments that can complete specific functions. The following description will specifically introduce the functions of each program module in this embodiment. Figure 5 As shown, the message push device 500 may include: a first acquisition module 501, a first determination module 502, a second acquisition module 503 and a second determination module 504, wherein: The first acquisition module 501 is used to acquire a message to be pushed to a target object; A first determination module 502 is used to determine the target type of the message to be pushed, where the target type includes a long-term message type or a one-time message type; A second acquisition module 503 is used to acquire the number of pushes of messages belonging to the target type according to the target atomic command associated with the target type; The second determination module 504 is used to determine whether to push the message to be pushed to the target object according to the number of push times.

[0095] As an optional embodiment, the target type is the long-term message type, the long-term message type is associated with the first atomic command in the target atomic command, and the first atomic command is used for pushing times statistics of the ordered set; Correspondingly, according to the target atomic command associated with the target type, the number of pushes of messages belonging to the target type is obtained, including: Obtain an ordered set corresponding to the target object; Determine, according to the ordered set, a first push count of the message belonging to the long-term message type by using the first atomic command; Wherein, when the first push number is less than a first preset threshold, the message to be pushed is pushed to the target object.

[0096] As an optional embodiment, determining, according to the ordered set, by using the first atomic command, a first push count of the message belonging to the long-term message type includes: According to the preset window granularity and statistical rules, determine the current time window and the statistical time window in the ordered set; Determine the number of pushes in the current time window through the first atomic command; Obtain the number of pushes in the statistical time window; The number of pushes in the current time window and the number of pushes in the statistical time window are summed to obtain the first number of pushes.

[0097] As an optional embodiment, the device 500 is further used for: When the first number of pushes is greater than a first preset threshold, the message to be pushed is intercepted, and the number of pushes in the current time window is corrected.

[0098] As an optional embodiment, the device 500 is further used for: According to a preset rule, determining an expiration time window in the ordered set; Clear the expiration time window and the corresponding number of pushes.

[0099] As an optional embodiment, the target type is the one-time message type, the one-time message type is associated with a second atomic command in the target atomic command, the second atomic command is used to count the number of pushes for a key-value pair, and the value of the key-value pair is the number of pushes; Correspondingly, according to the target atomic command associated with the target type, the number of pushes of messages belonging to the target type is obtained, including: Obtaining a second push count of the message belonging to the one-time message type through the second atomic command and the preset first key-value pair; When the second push count is less than a second preset threshold, obtaining a third push count of the message for the target object and belonging to the one-time message type by using the second atomic command and a preset second key-value pair; Wherein, when the third number of pushes is less than a third preset threshold, the message to be pushed is pushed to the target object.

[0100] As an optional embodiment, the device 500 is further used for: When the second push number is greater than the second preset threshold, intercepting the message to be pushed and correcting the value of the first key-value pair; or When the third number of pushes is greater than the third preset threshold, the message to be pushed is intercepted and the value of the second key-value pair is corrected.

[0101] Embodiment 3 Figure 6 The schematic diagram of the hardware architecture of a computer device 10000 suitable for implementing the message push method according to the third embodiment of the present application is shown schematically. In some embodiments, the computer device 10000 may be a terminal device such as a smart phone, a wearable device, a tablet computer, a personal computer, a vehicle terminal, a game console, a virtual device, a workbench, a digital assistant, a set-top box, a robot, etc. In other embodiments, the computer device 10000 may be a rack server, a blade server, a tower server, or a cabinet server (including an independent server, or a server cluster composed of multiple servers), etc. Figure 6 As shown, the computer device 10000 includes but is not limited to: a memory 10010, a processor 10020, and a network interface 10030 that can communicate with each other through a system bus. Among them: The memory 10010 includes at least one type of computer-readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (such as SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 10010 can be an internal storage module of the computer device 10000, such as a hard disk or memory of the computer device 10000. In other embodiments, the memory 10010 can also be an external storage device of the computer device 10000, such as a plug-in hard disk equipped on the computer device 10000, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. Of course, the memory 10010 can also include both the internal storage module of the computer device 10000 and its external storage device. In this embodiment, the memory 10010 is generally used to store the operating system and various application software installed in the computer device 10000, such as program codes of the message push method, etc. In addition, the memory 10010 can also be used to temporarily store various data that have been output or will be output.

[0102] In some embodiments, the processor 10020 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other chips. The processor 10020 is generally used to control the overall operation of the computer device 10000, such as performing control and processing related to data interaction or communication with the computer device 10000. In this embodiment, the processor 10020 is used to run the program code stored in the memory 10010 or process data.

[0103] The network interface 10030 may include a wireless network interface or a wired network interface, and the network interface 10030 is generally used to establish a communication link between the computer device 10000 and other computer devices. For example, the network interface 10030 is used to connect the computer device 10000 to an external terminal through a network, and to establish a data transmission channel and a communication link between the computer device 10000 and the external terminal. The network may be a wireless or wired network such as an intranet, the Internet, the Global System of Mobile communication (GSM), Wideband Code Division Multiple Access (WCDMA), 4G network, 5G network, Bluetooth, Wi-Fi, etc.

[0104] It should be pointed out that Figure 6 Only a computer device having components 10010 - 10030 is shown, but it should be understood that implementation of all of the components shown is not a requirement, and more or fewer components may alternatively be implemented.

[0105] In this embodiment, the message push method stored in the memory 10010 can also be divided into one or more program modules and executed by one or more processors (such as processor 10020) to complete the embodiment of the present application.

[0106] Embodiment 4 An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, wherein when the computer program is executed by a processor, the steps of the message push method in the embodiment are implemented.

[0107] In this embodiment, the computer-readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the computer-readable storage medium may be an internal storage unit of a computer device, such as a hard disk or memory of the computer device. In other embodiments, the computer-readable storage medium may also be an external storage device of a computer device, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the computer device. Of course, the computer-readable storage medium may also include both the internal storage unit of the computer device and its external storage device. In this embodiment, the computer-readable storage medium is generally used to store an operating system and various application software installed on the computer device, such as the program code of the message push method in the embodiment, etc. In addition, the computer-readable storage medium may also be used to temporarily store various types of data that have been output or are to be output.

[0108] Embodiment 5 An embodiment of the present application also provides a computer program product, including a computer program, which implements the method in the above embodiment when executed by a processor.

[0109] Obviously, those skilled in the art should understand that the modules or steps of the above-mentioned embodiments of the present application can be implemented by general-purpose computer devices, they can be concentrated on a single computer device, or distributed on a network composed of multiple computer devices, optionally, they can be implemented by executable program codes of computer devices, so that they can be stored in a storage device and executed by the computer device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. In this way, the embodiments of the present application are not limited to any specific combination of hardware and software.

[0110] It should be noted that the above are only preferred embodiments of the present application, and the patent protection scope of the present application is not limited thereto. Any equivalent structure or equivalent process transformation made using the contents of the specification and drawings of the present application, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. A message push method, characterized in that: The method comprises: Get the message to be pushed to the target object; Determine a target type of the message to be pushed, where the target type includes a long-term message type or a one-time message type; According to the target atomic command associated with the target type, obtaining the number of pushes of messages belonging to the target type; According to the number of pushes, it is determined whether to push the message to be pushed to the target object.

2. The method according to claim 1, characterized in that: The target type is the long-term message type, the long-term message type is associated with the first atomic command in the target atomic command, and the first atomic command is used for pushing times statistics of the ordered set; Correspondingly, according to the target atomic command associated with the target type, the number of pushes of messages belonging to the target type is obtained, including: Obtain an ordered set corresponding to the target object; Determine, according to the ordered set, a first push count of the message belonging to the long-term message type by using the first atomic command; Wherein, when the first push number is less than a first preset threshold, the message to be pushed is pushed to the target object.

3. The method according to claim 2, characterized in that Determining, according to the ordered set, by using the first atomic command, a first push count of the message belonging to the long-term message type, comprising: According to the preset window granularity and statistical rules, determine the current time window and the statistical time window in the ordered set; Determine the number of pushes in the current time window through the first atomic command; Obtain the number of pushes in the statistical time window; The number of pushes in the current time window and the number of pushes in the statistical time window are summed to obtain the first number of pushes.

4. The method according to claim 2, characterized in that: Also includes: When the first number of pushes is greater than a first preset threshold, the message to be pushed is intercepted, and the number of pushes in the current time window is corrected.

5. The method according to claim 2, characterized in that: The method further comprises: According to a preset rule, determining an expiration time window in the ordered set; Clear the expiration time window and the corresponding number of pushes.

6. The method according to claim 1, characterized in that The target type is the one-time message type, the one-time message type is associated with the second atomic command in the target atomic command, the second atomic command is used to count the number of pushes for a key-value pair, and the value of the key-value pair is the number of pushes; Correspondingly, according to the target atomic command associated with the target type, the number of pushes of messages belonging to the target type is obtained, including: Obtaining a second push count of the message belonging to the one-time message type through the second atomic command and the preset first key-value pair; When the second push count is less than a second preset threshold, obtaining a third push count of the message for the target object and belonging to the one-time message type by using the second atomic command and a preset second key-value pair; Wherein, when the third number of pushes is less than a third preset threshold, the message to be pushed is pushed to the target object.

7. The method according to claim 6, characterized in that Also includes: When the second push number is greater than the second preset threshold, intercepting the message to be pushed and correcting the value of the first key-value pair; or When the third number of pushes is greater than the third preset threshold, the message to be pushed is intercepted and the value of the second key-value pair is corrected.

8. A message push device, characterized in that: The device comprises: A first acquisition module is used to acquire a message to be pushed to a target object; A first determination module is used to determine the target type of the message to be pushed, where the target type includes a long-term message type or a one-time message type; A second acquisition module, configured to acquire the number of pushes of messages belonging to the target type according to a target atomic command associated with the target type; The second determination module is used to determine whether to push the message to be pushed to the target object according to the number of push times.

9. A computer device, characterized in that: include: at least one processor; and a memory communicatively connected to the at least one processor; wherein: The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the message pushing method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and when the computer instructions are executed by a processor, the message pushing method according to any one of claims 1 to 7 is implemented.

11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the message pushing method described in claims 1 to 7 are implemented.