Resource reminding method and device and electronic equipment
By traversing and reminding the resource expiration time that meets the conditions in the cached ordered set, the problem of system IO times and load increase when resource expiration reminders in the existing technology is solved, and more efficient resource reminder processing is achieved.
Patent Information
- Application Number
- CN202411482295.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-23
- Publication Date
- 2025-02-07
AI Technical Summary
In the prior art, when user resources expire reminder, the entire database table needs to be scanned, resulting in an increase in the number of system IO times and an increase in load.
By obtaining the reminder expiration time of the resource, iterates over elements in the cached ordered collection, and uses the characteristics of sorting elements by resource expiration time. Only when the resource expiration time of the current traversing element is different from the current time of the reminder expiration time is no greater than the reminder expiration time. , and continue to traverse; stop traversing when the time difference is greater than the reminder expiration time.
It effectively reduces the number of IO times in the system, reduces the system load, and improves the system performance.
Smart Images

Figure CN119398731A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer application technology, and in particular to a resource reminder method, device and electronic device. Background Art
[0002] In real life, many resources (such as traffic packages, server resources, application memberships, etc.) require users to subscribe before they can be used, and they are prepaid models, and the validity period of different resources is also different. In order to provide users with a better user experience, users are usually reminded when the subscribed resources expire.
[0003] At present, the common way to remind users of resource expiration is to scan the expiration time of all users' subscribed resources in the entire database table when the reminder time is reached (for example, 3 days before expiration, 2 days before expiration), and remind the users when the expiration time reaches the reminder time. In this way, the entire database table must be scanned every time a reminder is required, which will increase the system IO times and the system load. Summary of the invention
[0004] In order to solve the above technical problem or at least partially solve the above technical problem, at least one embodiment of the present disclosure provides a resource reminder method, device and electronic device.
[0005] In a first aspect, the present disclosure provides a resource reminder method, comprising:
[0006] Get the reminder expiration time of the resource;
[0007] Traversing the elements in the cache ordered set to obtain the currently traversed element, wherein the elements in the cache ordered set are sorted according to resource expiration time;
[0008] If the time difference between the resource expiration time of the currently traversed element and the current time is not greater than the reminder expiration time, perform a resource reminder based on the time difference, and continue to traverse the next element in the cache ordered set;
[0009] When the time difference between the resource expiration time of the currently traversed element and the current time is greater than the reminder expiration time, the traversal of the cache ordered set is stopped.
[0010] In a second aspect, the present disclosure provides a resource reminder device, including:
[0011] A first acquisition module is used to acquire a reminder expiration time corresponding to an application providing a resource;
[0012] A second acquisition module is used to traverse the elements in the cache ordered set to obtain the current traversal element, wherein the elements in the cache ordered set are sorted according to resource expiration time;
[0013] A reminder module, configured to, when the time difference between the resource expiration time of the currently traversed element and the current time is not greater than the reminder expiration time, perform a resource reminder based on the time difference, and continue to traverse the next element in the cache ordered set;
[0014] The second acquisition module is also used to stop traversing the cache ordered set when the time difference between the resource expiration time of the currently traversed element and the current time is greater than the reminder expiration time, and to continue traversing the next element in the cache ordered set when the time difference between the resource expiration time of the currently traversed element and the current time is not greater than the reminder expiration time.
[0015] In a third aspect, the present disclosure provides an electronic device, including: a processor and a memory;
[0016] The processor is used to execute the resource reminder method as described in the first aspect above by calling the program or instruction stored in the memory.
[0017] In a fourth aspect, the present disclosure provides a computer-readable storage medium, wherein the computer-readable storage medium stores a program or instruction, wherein the program or instruction enables a computer to execute the resource reminder method as described in the first aspect.
[0018] In a fifth aspect, the present disclosure provides a computer program product, wherein the computer program product is used to execute the resource reminder method as described in the first aspect.
[0019] Compared with the prior art, the technical solution provided by the embodiments of the present disclosure has at least the following advantages:
[0020] In the disclosed embodiment, the reminder expiration time of the resource is obtained, and the elements in the cache ordered set are traversed to obtain the currently traversed element, wherein the elements in the cache ordered set are sorted according to the resource expiration time, and when the time difference between the resource expiration time of the currently traversed element and the current time is not greater than the reminder expiration time, a resource reminder is made based on the time difference, and the traversal of the next element in the cache ordered set continues; when the time difference between the resource expiration time of the currently traversed element and the current time is greater than the reminder expiration time, the traversal of the cache ordered set is stopped. With the above technical solution, by sorting and storing the resource expiration times in the cache ordered set, and traversing the elements in the cache ordered set to make resource reminders, when the time difference between the resource expiration time of the currently traversed element and the current time is greater than the reminder expiration time, it can be determined that the currently traversed element and its subsequent elements in the cache ordered set do not meet the reminder timing, so there is no need to read subsequent elements, thereby effectively reducing the number of IO times of the system, helping to reduce system load and improve system performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0022] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0023] Figure 1 A flowchart of a resource reminder method provided by an exemplary embodiment of the present disclosure;
[0024] Figure 2 A flowchart of a resource reminder method provided by another exemplary embodiment of the present disclosure;
[0025] Figure 3 A schematic diagram showing a user purchasing resource table according to an exemplary embodiment of the present disclosure;
[0026] Figure 4 A schematic diagram showing a process of a resource reminder method provided by a specific embodiment of the present disclosure is shown;
[0027] Figure 5 A schematic diagram of the structure of a resource reminder device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0028] In order to more clearly understand the above-mentioned purposes, features and advantages of the present disclosure, the present disclosure is further described in detail below in conjunction with the accompanying drawings and embodiments. It is understandable that the described embodiments are part of the embodiments of the present disclosure, rather than all of the embodiments, and the specific embodiments described herein are only used to explain the present disclosure, rather than to limit the present disclosure. In the absence of conflict, the embodiments of the present disclosure and the features in the embodiments can be combined with each other. Based on the described embodiments of the present disclosure, all other embodiments obtained by ordinary technicians in the field belong to the scope of protection of the present disclosure.
[0029] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.
[0030] Before explaining the specific implementation methods of the present disclosure, the Chinese and English technical terms that may be involved in the present disclosure are explained as follows:
[0031] Scheduled tasks: including but not limited to xxl-job, SchedulerX, etc., mainly used to execute certain tasks at fixed time points or periodically;
[0032] RedisZset: is an ordered set. Each element stored in the ordered set is equivalent to two values, one is the element value member of the ordered set, and the other is the sorting value score. The score in the ordered set can be repeated, but there cannot be repeated members. In addition, new elements added to the set will be automatically sorted.
[0033] Delay queue: DelayQueue, also called delay queue, the messages in the delay queue will be assigned a delay time when entering the queue, and will be processed after the specified delay time.
[0034] The present disclosure provides a resource reminder method, which aims to provide resource reminders for two situations. One situation is that for users who intend to use the resources for a long time, multiple reminders are made when the resources are about to expire, so as to encourage the users to renew in advance without affecting the user's use, thereby improving the renewal rate of users who intend to use the resources for a long time; the other situation is that for users who intend to use the resources for a long time, they may not use the resources for a long time due to various reasons. Through this solution, the users can be reminded to use the resources, so as to improve the user's utilization rate of the resources and not waste resources.
[0035] The specific implementation of the resource reminder method, device and electronic device disclosed in the present invention is explained in detail below with reference to the accompanying drawings.
[0036] Figure 1A flow chart of a resource reminder method provided for an exemplary embodiment of the present disclosure. The method can be executed by a resource reminder device provided for an embodiment of the present disclosure. The resource reminder device can be implemented using software and / or hardware and can be integrated in an electronic device, which can be a server.
[0037] like Figure 1 As shown, the resource reminder method may include the following steps:
[0038] Step 101, obtaining the reminder expiration time of the resource.
[0039] The reminder expiration time is used to indicate how long the resource will expire before a reminder is issued. For example, if the reminder expiration time is 2 days, it means that an expiration reminder will be issued when the resource expires 2 days later.
[0040] In this embodiment, for a resource, its reminder expiration time can be one or more. When the reminder expiration time is one, that is, a reminder is made when the resource has the remaining reminder expiration time. For example, if the reminder expiration time is 0 days, a reminder is made on the day when the resource expires. For another example, if the reminder expiration time is 2 days, a reminder is made when the resource has 2 days left to expire. When there are multiple reminder expiration times, multiple reminders are made before the resource expires. For example, if the reminder expiration time is 3 days and 1 day, a reminder is made when the resource has 3 days left to expire, and another reminder is made when the resource has 1 day left to expire.
[0041] As an example, the reminder expiration time of a resource may be written into the code and provided, and the reminder expiration time of the resource may be obtained by reading the code.
[0042] As an example, the reminder expiration time of a resource can be configured through a configuration file. The reminder requirements corresponding to each resource may be different, and the corresponding reminder expiration time is also different. In this example, for each resource, its corresponding reminder expiration time can be configured in the configuration file in advance and the configuration file can be saved. The configuration file corresponding to the resource is obtained, and then the configuration file is read to obtain the reminder expiration time of the resource. It can be understood that different applications that provide resources usually correspond to different servers, and the resources corresponding to the same application usually have the same reminder expiration time. Therefore, the corresponding configuration file can be configured for the application, and the configuration file is stored in the corresponding server. The server determines the reminder expiration time of the resource provided by the application by obtaining the stored configuration file. Therefore, by configuring the reminder expiration time of the resource in the configuration file, the flexibility is strong. When the reminder expiration time needs to be modified, the configuration file can be modified without modifying the code. When the number of reminders needs to be increased, it is only necessary to modify the configuration file and create a corresponding delay queue, thereby achieving scalability.
[0043] Step 102: traverse the elements in the cache ordered set to obtain the current traversal element, wherein the elements in the cache ordered set are sorted according to resource expiration time.
[0044] In this embodiment, a plurality of elements are stored in the cache ordered set, each element at least including a user resource identifier and a corresponding resource expiration time, the resource expiration time of each element may be the same, but the user resource identifier is unique. Each element is sorted in the cache ordered set according to the resource expiration time, for example, each element may be sorted in ascending or descending order according to the resource expiration time.
[0045] Among them, the resource expiration time of the first element in the cache ordered set is the earliest, and the resource expiration time of the last element is the latest. From the first element to the last element, the resource expiration time becomes later and later. For multiple elements with the same resource expiration time, the multiple elements can be sorted according to the time of entering the cache ordered set. For example, there are 3 elements with the earliest resource expiration time, then the first element of the cache ordered set is the one of the 3 elements that enters the cache ordered set the earliest, the element that enters the cache valid set the second earliest is the second element, and the one of the 3 elements that enters the cache ordered set the latest is the third element of the cache ordered set.
[0046] In this embodiment, the currently traversed element is obtained by traversing the elements in the cache ordered set.
[0047] As an example, when obtaining an element from a cache ordered set, you can start from the first element, traverse the elements in the cache ordered set in sequence, obtain the currently traversed element, and stop obtaining the elements in the cache ordered set when the condition for stopping traversal is met, and this reminder process ends. Since the expiration time of the first element is the earliest, the cache ordered set is traversed from the first element until the time difference between the expiration time of the currently traversed element and the current time is greater than the reminder expiration time, that is, the condition for stopping traversal is met, and the traversal is stopped, ensuring that each element in the cache ordered set that needs to be reminded of the expiration time is read out, without having to read subsequent elements that do not need to be reminded of the expiration time, thereby minimizing the number of system IO times.
[0048] As another example, when obtaining elements from a cached ordered set, any element in the cached ordered set can be read as the currently traversed element. Since the elements in the cached ordered set are arranged in order of expiration time, if the time difference between the expiration time of the currently traversed element and the current time is not greater than the reminder expiration time, it can be determined that the currently traversed element to the first element in the cached ordered set are elements that need to be reminded. Then, each element is read in turn for expiration time reminder, and the next element of the currently traversed element is read, until the condition for stopping traversal is met, stop obtaining elements in the cached ordered set, and this reminder process ends. If the time difference between the expiration time of the currently traversed element and the current time is greater than the reminder expiration time, it can be determined that the current traversal element to the first element may or may not need an expiration reminder, and it can be determined that all elements after the currently traversed element do not need an expiration reminder. In this case, any element before the currently traversed element (with an expiration time not later than the expiration time of the currently traversed element) in the cache ordered set (preferably the first element of the cached ordered set) can be read as the new current traversal element, and the above process is repeated until the condition for stopping traversal is met, and the elements in the cached ordered set are stopped from being obtained, and this reminder process ends.
[0049] Step 103: When the time difference between the resource expiration time of the currently traversed element and the current time is not greater than the reminder expiration time, a resource reminder is performed based on the time difference, and the next element in the cache ordered set is continued to be traversed.
[0050] In this embodiment, for the currently traversed element obtained, the time difference between the resource expiration time of the currently traversed element and the current time can be calculated, and the obtained time difference can be compared with the reminder expiration time of the resource. If the time difference is less than or equal to the reminder expiration time, it can be determined that the current time has reached the reminder time of the resource, and then the resource reminder is performed based on the obtained time difference, and the next element in the cache ordered set is continued to be traversed, that is, the next adjacent element of the currently traversed element in the cache ordered set is obtained as the new currently traversed element, and the time difference between the resource expiration time of the new currently traversed element and the current time is calculated, and it is determined whether the time difference is greater than the reminder expiration time, and the resource reminder is performed when the time difference is less than or equal to the reminder expiration time, and the next element in the cache ordered set is continued to be traversed. Repeat the above process until the obtained time difference is greater than the reminder expiration time.
[0051] When a resource reminder is made based on a time difference, if the time difference is equal to the reminder expiration time, the purpose of making a reminder according to the reminder expiration time is achieved; if the time difference is inconsistent with the reminder expiration time, a reminder is made according to the time difference, which can promptly remind the user that the resource is about to expire.
[0052] It can be understood that resource reminders are reminders to users who have ordered resources. As an example, when performing resource reminders based on time differences, the user resource association table can be queried based on the user resource identifier of the currently traversed element to determine the user identifier, and then a resource reminder can be made to the user corresponding to the user identifier. For example, if the determined time difference is 3 days, a reminder message "The resource A you purchased will expire in 3 days" can be sent to the user. Among them, the user resource identifier can be a combination of a user identifier and a resource identifier. For example, the user resource identifier can be in the form of "user identifier_resource identifier". Since the user identifier is unique, the user resource identifier is also unique.
[0053] As another example, the elements in the cache ordered set include user information in addition to the user resource identifier and resource expiration time. The user information includes but is not limited to the user identifier. After obtaining the currently traversed element, the user information contained in the element is obtained. Then, when providing resource reminders based on the time difference, resource reminders can be provided to the user corresponding to the user information.
[0054] Step 104 , when the time difference between the resource expiration time of the currently traversed element and the current time is greater than the reminder expiration time, stop traversing the cache ordered set.
[0055] In the disclosed embodiment, for the currently traversed element obtained, if the time difference between the calculated resource expiration time of the currently traversed element and the current time is greater than the reminder expiration time of the resource, since the elements in the cache ordered set are sorted according to the resource expiration time, and traversal starts from the element with the earliest resource expiration time, it can be determined that starting from the currently traversed element in the cache ordered set, the remaining elements that have not been traversed are all those whose remaining time (i.e., the interval between the resource expiration time and the current time) is greater than the reminder expiration time, and the reminder timing has not been reached, so the traversal of the cache ordered set is stopped, and there is no need to obtain the unexpired resources from the cache ordered set and determine whether a reminder is needed, thereby effectively reducing the number of IO times the server reads the memory and reducing the server load.
[0056] In an optional implementation of the present disclosure, for resources that have been reminded, their corresponding elements are deleted from the cache ordered set, so that after the reminder process ends, the remaining elements in the cache ordered set are all elements for which the reminder time has not yet arrived.
[0057] In actual implementation, resource reminder actions can be performed through scheduled tasks. For example, a scheduled task can be configured on the scheduled task component to periodically (for example, at 08:00 every day) traverse the elements in the cache ordered set, determine whether the current traversal element has reached the reminder expiration time, and issue a reminder when the reminder expiration time is reached.
[0058] The resource reminder method of the disclosed embodiment obtains the reminder expiration time of the resource, traverses the elements in the cache ordered set to obtain the currently traversed element, wherein the elements in the cache ordered set are sorted according to the resource expiration time, and when the time difference between the resource expiration time of the currently traversed element and the current time is not greater than the reminder expiration time, the resource reminder is made based on the time difference, and the traversal of the next element in the cache ordered set continues; when the time difference between the resource expiration time of the currently traversed element and the current time is greater than the reminder expiration time, the traversal of the cache ordered set is stopped. The above technical solution is adopted, by sorting and storing the resource expiration time in the cache ordered set, and traversing the elements in the cache ordered set to make resource reminders, when the time difference between the resource expiration time of the currently traversed element and the current time is greater than the reminder expiration time, it can be determined that the currently traversed element and its subsequent elements in the cache ordered set do not meet the reminder timing, so there is no need to read the subsequent elements, thereby effectively reducing the number of IO times of the system, helping to reduce the system load and improve system performance.
[0059] In actual scenarios, a resource may need to be reminded multiple times before expiration, for example, once 7 days before expiration, once 3 days before expiration, and once on the day of expiration. Therefore, in an optional implementation of the present disclosure, there are multiple reminder expiration times, each with a different expiration time. In order to achieve the purpose of multiple reminders for the same resource by scanning the cache ordered set once, the element read from the cache ordered set can be added to the corresponding delay queue after a reminder is made, so as to achieve subsequent reminders. Figure 2 As shown, based on the above embodiments, the solution of the present disclosure may further include the following steps:
[0060] Step 201 : when the time difference between the resource expiration time of the currently traversed element and the current time is not greater than the reminder expiration time, determine a first reminder expiration time from multiple reminder expiration times that has the smallest difference with the time difference and is less than the time difference.
[0061] In this embodiment, if the time difference between the resource expiration time of the currently traversed element and the current time is not greater than the reminder expiration time, in addition to performing a resource reminder based on the time difference, a reminder expiration time that has the smallest difference with the time difference and is less than the time difference can also be determined from multiple reminder expiration times (for ease of description and distinction, referred to as the first reminder expiration time).
[0062] For example, assuming that the acquired reminder expiration times include 7 days, 3 days, and 1 day, and the determined time difference is 6, the determined first reminder expiration time is 3 days.
[0063] Step 202: Calculate the difference between the time difference and the first reminder expiration time to obtain a first delay time.
[0064] In this embodiment, after determining the first reminder expiration time, the difference between the first reminder expiration time and the time difference can be further calculated to obtain a delay time (referred to as the first delay time for ease of description and distinction). It should be noted that in this embodiment, the determined first delay time is a numerical value (i.e., does not contain a positive or negative sign). When performing the calculation, the first reminder expiration time can be subtracted from the time difference to ensure that the obtained first delay time is a positive number, thereby reducing the difficulty of data processing.
[0065] Step 203: Store the user resource identifier of the currently traversed element into a first delay queue corresponding to the first delay time.
[0066] In this embodiment, corresponding delay queues are pre-constructed for different delay times, for example, a delay time of 1 day corresponds to delay queue 1, a delay time of 2 days corresponds to delay queue 2, a delay time of 3 days corresponds to delay queue 3, and so on. After determining the first delay time, the user resource identifier of the currently traversed element can be stored in the delay queue corresponding to the first delay time (referred to as the first delay queue for ease of description and distinction). When the message in the first delay queue reaches the corresponding delay time, consumption begins and another resource reminder is performed. By constructing corresponding delay queues for different delay times, reminders can be made at different remaining times each time.
[0067] Further, in an optional embodiment of the present disclosure, if Figure 2 As shown, after step 203, the following steps may also be included:
[0068] Step 204: when the time length for the user resource identifier of the currently traversed element to enter the first delay queue reaches the first delay time, the user resource identifier is obtained from the first delay queue.
[0069] As an example, the timing may start when the user resource identifier of the currently traversed element is stored in the first delay queue, and when the timing duration reaches the first delay time, the corresponding user resource identifier is obtained from the first delay queue.
[0070] As another example, when the user resource identifier of the currently traversed element is stored in the first delay queue, a scheduled task can be created. The execution time of the scheduled task is the first delay time plus the current time. When the execution time is reached, the scheduled task obtains the corresponding user resource identifier from the first delay queue.
[0071] Step 205: query the user resource association table according to the user resource identifier to determine the latest expiration time of the resource subscribed by the user.
[0072] Among them, the user resource association table is automatically generated by the server. When the user orders resources for the first time, the server generates a user resource association relationship based on the resource identifier of the resource ordered by the user, the user identifier and the resource expiration time of the resource ordered this time, and stores it in the user resource association table in the database for query. The user resource association table in the database records the relevant information of resources purchased by different users, including user identifier, resource identifier, resource expiration time, etc. The resource expiration time of the resource ordered by the user can be queried from the user resource association table through the user resource identifier. Among them, the resource expiration time recorded in the user resource association table is the latest. When the user renews the resource, the resource expiration time in the user resource association table will be updated according to the user's renewal time.
[0073] In this embodiment, for the user resource identifier obtained from the first delay queue, the corresponding user resource association table can be queried according to the user resource identifier, and the resource expiration time of the resource subscribed by the user can be obtained from the user resource association table, thereby obtaining the latest expiration time of the resource.
[0074] Step 206: When the latest expiration time is consistent with the resource expiration time, a resource reminder is performed based on the first reminder expiration time.
[0075] In this embodiment, after obtaining the latest expiration time, the latest expiration time can be further compared with the resource expiration time of the currently traversed element in the cache ordered set to see if they are consistent. If the two are consistent, it means that the user has not renewed the resource, and then a resource reminder is made based on the first reminder expiration time to achieve reminders according to the configured reminder expiration time. For example, if the first reminder expiration time is 5 days, a reminder message "The resource A you subscribed has 5 days left to expire" can be sent to the relevant user.
[0076] Step 207: when the latest expiration time is consistent with the resource expiration time, determine a second reminder expiration time from the multiple reminder expiration times, which has the smallest difference with the first reminder expiration time and is smaller than the first reminder expiration time.
[0077] In this embodiment, when the latest expiration time is consistent with the resource expiration time of the currently traversed element in the cache ordered set, if the first reminder expiration time is not the minimum value among the multiple reminder expiration times, a reminder expiration time (for ease of description and distinction, referred to as the second reminder expiration time) that has the smallest difference with the first reminder expiration time and is less than the first reminder expiration time can also be determined from the multiple reminder expiration times.
[0078] For example, assuming that the acquired reminder expiration times include 7 days, 3 days, and 1 day, and the first reminder expiration time is 3 days, it can be determined that the second reminder expiration time is 1 day.
[0079] It should be noted that, in this embodiment, the execution order of step 206 and step 207 is not particular, and the two can be executed sequentially or simultaneously. Figure 2 The illustrated embodiment only takes step 207 being executed after step 206 as an example to explain the present disclosure, and cannot be used as a limitation to the present disclosure.
[0080] Step 208: Calculate the difference between the first reminder expiration time and the second reminder expiration time to obtain a second delay time.
[0081] In this embodiment, after the second reminder expiration time is determined, the difference between the first reminder expiration time and the second reminder expiration time may be further calculated, and the obtained difference may be determined as the second delay time.
[0082] Step 209, stores the user resource identifier of the currently traversed element in the second delay queue corresponding to the second delay time, so that when the time for the user resource identifier to enter the second delay queue reaches the second delay time and the latest expiration time of the resource subscribed by the user is consistent with the resource expiration time, a resource reminder is issued based on the second reminder expiration time.
[0083] In this embodiment, after determining the second delay time, the user resource identifier of the current traversal element can be stored in the second delay queue corresponding to the second delay time. It can be understood that the second delay queue and the first delay queue can be the same queue or different queues, which are specifically determined according to the second delay time. If the second delay time is the same as the first delay time, the second delay queue and the first delay queue are the same queue. If the second delay time is different from the first delay time, the second delay queue and the first delay queue are different queues. For the message (i.e., the user resource identifier) stored in the second delay queue, when the time it enters the second delay queue reaches the second delay time, the corresponding message is consumed from the second delay queue, and the corresponding user resource association table is queried according to the user resource identifier to determine the latest expiration time, and when the latest expiration time is consistent with the resource expiration time of the current traversal element obtained from the cache ordered set, a resource reminder is performed based on the second reminder expiration time; if the latest expiration time is inconsistent with the resource expiration time, it indicates that the user has renewed the resource, and the latest expiration time and the user resource identifier are added as new elements to the cache ordered set. For the message that has been consumed from the delay queue, it is deleted from the delay queue where it is located.
[0084] In an optional implementation of the present disclosure, in the case where the time for the user resource identifier to enter the second delay queue reaches the second delay time and the latest expiration time of the resource ordered by the user is consistent with the resource expiration time, in addition to performing a resource reminder based on the second reminder expiration time, it is also possible to determine whether the second reminder expiration time is the minimum value of multiple reminder expiration times (i.e., the last reminder expiration time). If the second reminder expiration time is not the minimum value of multiple reminder expiration times, a third reminder expiration time with the minimum difference from the second reminder expiration time and less than the second reminder expiration time is determined from multiple reminder expiration times, the difference between the second reminder expiration time and the third reminder expiration time is calculated to obtain a fourth delay time, and the user resource identifier is stored in a fourth delay queue corresponding to the fourth delay time, and then when the fourth delay time arrives, the user resource identifier is consumed from the fourth delay queue, and a resource reminder is performed based on the third reminder expiration time when the latest expiration time is consistent with the resource expiration time, and it is continued to be determined whether the third reminder expiration time is the minimum value of multiple reminder expiration times. Repeat the above process until the minimum value of multiple reminder expiration times is traversed. Assuming that the second reminder expiration time is the minimum value among multiple reminder expiration times, in this case, it can be further determined whether the second reminder expiration time is 0. If it is 0, it means that the reminder is being given when the resource expires. After the resource reminder is given based on the second reminder expiration time, the resource has expired, and the state of the resource in the resource table can be updated to an available state to release the resource so that other users can subscribe to the resource. If the second reminder expiration time is not 0, the second reminder expiration time is used as the third delay time, and the user resource identifier of the currently traversed element is stored in the third delay queue corresponding to the third delay time, so that when the time for the user resource identifier to enter the third delay queue reaches the third delay time and the latest expiration time of the resource subscribed by the user is consistent with the resource expiration time, a reminder of resource expiration is given. In this way, when the reminder expiration time corresponding to the resource does not include a reminder on the day of expiration, a reminder can be given on the day of resource expiration, thereby improving the user experience.
[0085] In the embodiment of the present disclosure, for a user whose resources have expired, the user's related resource subscription information is deleted from the user resource association table.
[0086] Step 210: When the latest expiration time is inconsistent with the resource expiration time, the latest expiration time and the user resource identifier are added as new elements to the cache ordered set.
[0087] In an embodiment of the present disclosure, when the latest expiration time of a resource recorded in a user resource association table is inconsistent with the resource expiration time recorded in a cache ordered set, it can be determined that the user has renewed the resource. In this case, the latest expiration time and the user resource identifier are added as new elements to the cache ordered set, and the elements entering the cache ordered set are sorted according to the latest resource expiration time. When the user renews the resource, there is no need to issue resource reminders for tasks consumed from the delay queue, and the consumed tasks are deleted from the delay queue, thereby avoiding the need to continue processing whether to remind the user of the renewed resource before it expires, thereby reducing unnecessary processing load.
[0088] The resource reminder method of this embodiment determines the delay time of the next reminder when there are multiple reminder expiration times and adds the user resource identifier of the currently traversed element to the delay queue corresponding to the delay time, and then consumes messages from the delay queue when the delay time arrives to remind again until the resource expires and the resource is released. Therefore, the reminder action can be easily executed after the delay time. When multiple reminders are required for the same resource, it is only necessary to obtain the element that reaches the reminder time from the cache ordered set once, without having to obtain it from the cache ordered set every time a reminder is made, which further reduces the number of IO times and reduces the load on the server.
[0089] In an optional implementation of the present disclosure, a user who has not used resources for a long time can also be reminded to use them, so as to improve the utilization rate of resources and prevent excessive waste of resources. The reminder time for the user who has not used resources for a certain number of days can be configured through code or configuration files. It is easy to modify when configured through configuration files, and the flexibility is strong. That is, the configuration file can configure the reminder expiration time of the resource, and can also configure the reminder time of the resource. In the case of configuring the reminder time through the configuration file, in this embodiment, the configured reminder time can be obtained from the configuration file, and the user resource purchase table corresponding to the user resource identifier of the current traversal element can be read to obtain the user's most recent use of the resource, and the difference between the use time and the current time is calculated to obtain the interval unused time. If the obtained interval unused time is greater than or equal to the reminder time, the user corresponding to the user identifier in the user purchase resource table can be reminded of the long-term non-use of the resource. For example, assuming that the reminder time is 3 days, and the calculated interval unused time is 3 days, a reminder message such as "the resource A you ordered has not been used for 3 days, please use it in time" can be sent to the user corresponding to the user identifier in the user purchase resource table.
[0090] In an optional implementation of the present disclosure, resource usage reminders can also be made only for users with high usage frequency to reduce the number of reminders. Users with high usage frequency refer to users whose usage frequency reaches a preset usage frequency threshold. The usage frequency threshold can be configured in the configuration file together with the usage reminder time. In this embodiment, the usage frequency threshold and the usage reminder time can be obtained from the configuration file, and the user resource purchase table corresponding to the user resource identifier of the current traversal element can be read to obtain the usage time of the user's most recent use of the resource and the usage frequency of the user's use of the resource, calculate the difference between the usage time and the current time, and obtain the interval unused time. When the interval unused time reaches (i.e., greater than or equal to) the usage reminder time and the usage frequency is greater than the usage frequency threshold, the user corresponding to the user identifier in the user purchase resource table is reminded of long-term non-use of resources. For example, assuming that the usage reminder time is 3 days, the calculated interval unused time is 4 days, the usage frequency is 0.6, and the usage frequency threshold is 0.5, then a usage reminder message such as "the resource A you ordered has not been used for 4 days, please use it in time" can be sent to the user corresponding to the user identifier in the user purchase resource table.
[0091] Among them, the user purchase resource table can be generated when the user purchases the resource. Figure 3 A schematic diagram of a user purchasing resource table of an exemplary embodiment of the present disclosure is shown as follows: Figure 3 As shown, after the user purchases a resource, he will obtain relevant information about the purchased resource, including resource identification id and resource status status, where resource id uniquely identifies the resource, and status is used to identify whether the resource is used. When the value of status is "1", it means that the resource is used, and when the value of status is "0", it means that the resource is not used. A user purchase resource table is generated based on the relevant information of the user and the relevant information of the resource, where the relevant information of the user includes but is not limited to the user identification id, user name, etc. The user id uniquely identifies the user. Figure 3As shown, the user purchase resource table includes the user purchase resource unique identification id, which can be automatically assigned by the server, user_id represents the user id, resource_id represents the resource id of the resource purchased by the user, valid_date represents the resource expiration time of the resource purchased by the user, and the resource expiration time is the latest, use_ratio represents the frequency of user use of resources, and the frequency of use is calculated according to different calculation rules based on different services after each user uses the resource, and then the value of this field in the table is updated; last_user_date in the user purchase resource table represents the time when the user last used the resource, and the value of this field in this table is updated each time the user uses the resource. The user purchase resource table can use the user resource identification as an index, and the unique user resource identification can be queried through the index, wherein the user resource identification can be a combination of the user id and the resource id, for example, the user resource identification can be user id_resource id.
[0092] In this embodiment, a scheduled task (for example, 08:00 every day) can be configured to periodically read the user resource purchase table in the database, and remind users who have not used resources for a long time to use resources, so as to monitor the resource usage rate.
[0093] It should be noted that in the embodiment of the present disclosure, the current time, reminder expiration time and reminder usage time are all expressed in days (ie, dates) as the smallest unit.
[0094] Figure 4 A schematic diagram of a resource reminder method according to a specific embodiment of the present disclosure is shown. Figure 4 As shown, when a user purchases resources from the service end (i.e., the server) for the first time, he selects the expiration time of the purchased resources. The server will query the resource table in the database to obtain available resources with resource status status = 0, and the database returns the resource id of the available resource. After the server obtains feedback, it requests to use the resource, sets the status of the requested resource to 1, and updates the status of the corresponding resource in the resource table to 1 based on the resource id, and generates a user resource association relationship based on the user id, resource id and expiration timestamp (i.e., resource expiration time), and passes the association relationship to the user resource association table in the database for storage. The information of a resource purchased by a user is stored as an element in the user resource usage cache in rediszset. The structure of an element is as follows:
[0095] Key: user-resource, i.e. user resource identifier;
[0096] Score: the expiration timestamp of the resource purchased by the user, that is, the resource expiration time;
[0097] Member: User information, including but not limited to user ID, user name, etc.
[0098] If the user renews the resource, the server will modify the resource expiration time according to the user's renewal period, and modify the expiration time field value of the corresponding user in the user resource association table to the latest expiration time.
[0099] like Figure 4 As shown, the server can periodically execute the task of querying the user resource usage data that is about to expire through a scheduled task. When querying the user resource usage data that is about to expire, it is necessary to query the configuration file to obtain the pre-configured reminder expiration time (n; m; k...), where n is the largest in the reminder expiration time and decreases one by one. By configuring the reminder expiration time, the first reminder can be realized when there are n days left before expiration, the second reminder when there are m days left before expiration, the third reminder when there are k days left before expiration, etc. It is also necessary to loop through the user resource usage cache in rediszset and take out the elements. If the value of the resource expiration time of the current traversal element in zset is less than or equal to n days, the user resource usage is notified that it will expire after n days. At the same time, the delay time (delay time = nm) is calculated and the user resource identifier and resource expiration time of the current traversal element are added to the delay queue 1 corresponding to the delay time. The elements in zset are sorted in ascending order according to the resource expiration time. Based on this feature, if the value of the resource expiration time of the current traversal element in zset minus the current timestamp is greater than n days, the traversal is stopped because the remaining expiration time must be greater than n days, and the reminder process ends.
[0100] like Figure 4 As shown, for tasks entering delay queue 1, a scheduled task can be created as a consumer to consume tasks in the delay queue. The execution process is as follows:
[0101] Step 1: Delay the consumption of tasks in queue 1 after reaching the delay time. Each time one is taken out, the same process is performed as follows: query the latest expiration time of the user from the user resource association table in the database. If the latest expiration time in the database = the resource expiration time in the queue, put the user resource identifier and resource expiration time into delay queue 2, and the delay time is: mk; otherwise (in this case, the user must have renewed the resource), store the latest expiration time and user resource identifier of the user resource as new elements in the user resource usage cache of rediszset for automatic sorting.
[0102] Step 2: Repeat this step according to the configured reminder expiration time of multiple reminders. Each time it is executed, the delay time is the next value of the time parsed from the configuration file minus the previous value. If the user does not renew, the user resource identifier and resource expiration time are added to the delay queue corresponding to the delay time until the delay queue corresponding to the last delay time is executed.
[0103] Step 3: Execution of the delay queue task corresponding to the last delay time. This is the last time to take out data from the delay queue for a resource. Each time a resource is taken out, the same process is performed as follows: If the user's current timestamp = the expiration timestamp of the resource subscribed by the user in zset, notify the user that the resource usage has expired, and modify the status of the resource in the resource table to 0, and delete the user-related information in the user resource association table; otherwise (in this case, the user must have renewed the resource), the latest expiration time of the user resource and the user resource identifier are stored as new elements in the user resource usage cache of rediszset.
[0104] In order to implement the above embodiments, the present disclosure further provides a resource reminder device, which can be implemented by software and / or hardware and can be integrated in an electronic device.
[0105] Figure 5 A schematic diagram of the structure of a resource reminder device provided by an embodiment of the present disclosure is shown in FIG. Figure 5 As shown, the resource reminder device 30 may include: a first acquisition module 310 , a second acquisition module 320 and a reminder module 330 .
[0106] Wherein, the first acquisition module 310 is used to obtain the reminder expiration time corresponding to the application providing the resource;
[0107] A second acquisition module 320 is used to traverse the elements in the cache ordered set to obtain the current traversal element, wherein the elements in the cache ordered set are sorted according to the resource expiration time;
[0108] The reminder module 330 is used to make a resource reminder based on the time difference when the time difference between the resource expiration time of the currently traversed element and the current time is not greater than the reminder expiration time, and continue to traverse the next element in the cache ordered set;
[0109] The second acquisition module 320 is also used to stop traversing the cache ordered set when the time difference between the resource expiration time of the currently traversed element and the current time is greater than the reminder expiration time, and to continue traversing the next element in the cache ordered set when the time difference between the resource expiration time of the currently traversed element and the current time is not greater than the reminder expiration time.
[0110] Optionally, there are multiple reminder expiration times, each reminder expiration time is different; the resource reminder device 30 further includes:
[0111] A first determination module, configured to determine, from a plurality of reminder expiration times, a first reminder expiration time having a minimum difference from the time difference and being less than the time difference, when the time difference between the resource expiration time of the currently traversed element and the current time is not greater than the reminder expiration time;
[0112] A first calculation module, used for calculating the difference between the time difference and the first reminder expiration time to obtain a first delay time;
[0113] The first writing module is used to store the user resource identifier of the currently traversed element into a first delay queue corresponding to the first delay time.
[0114] Further optionally, the resource reminder device 30 further includes:
[0115] A first consumption module, configured to obtain the user resource identifier from the first delay queue when the time length for the user resource identifier of the currently traversed element to enter the first delay queue reaches a first delay time;
[0116] The first query module is used to query the user resource association table according to the user resource identifier to determine the latest expiration time of the resource ordered by the user;
[0117] The reminder module 330 is further configured to, when the latest expiration time is consistent with the resource expiration time, perform a resource reminder based on the first reminder expiration time.
[0118] Further optionally, the resource reminder device 30 further includes:
[0119] A second determination module is used to determine, from the plurality of reminder expiration times, a second reminder expiration time that has the smallest difference from the first reminder expiration time and is smaller than the first reminder expiration time when the latest expiration time is consistent with the resource expiration time;
[0120] A second calculation module, used for calculating the difference between the first reminder expiration time and the second reminder expiration time to obtain a second delay time;
[0121] The second writing module is used to store the user resource identifier of the currently traversed element into the second delay queue corresponding to the second delay time, so that when the time for the user resource identifier to enter the second delay queue reaches the second delay time and the latest expiration time of the resource subscribed by the user is consistent with the resource expiration time, a resource reminder is issued based on the second reminder expiration time.
[0122] Optionally, the resource reminder device 30 further includes:
[0123] a third determining module, configured to, when the second reminder expiration time is the minimum value among the plurality of reminder expiration times, use the second reminder expiration time as the third delay time if the second reminder expiration time is not 0;
[0124] The third writing module is used to store the user resource identifier of the currently traversed element into the third delay queue corresponding to the third delay time, so as to issue a resource expiration reminder when the time when the user resource identifier enters the third delay queue reaches the third delay time and the latest expiration time of the resource ordered by the user is consistent with the resource expiration time.
[0125] Optionally, the resource reminder device 30 further includes:
[0126] When the latest expiration time is inconsistent with the resource expiration time, the latest expiration time and the user resource identifier are added as new elements to the cache ordered set.
[0127] Optionally, the first acquisition module 310 is further configured to:
[0128] Get the configuration file corresponding to the resource;
[0129] Read the configuration file to get the reminder expiration time.
[0130] Optionally, the resource reminder device 30 further includes:
[0131] A usage configuration acquisition module is used to obtain a usage frequency threshold and a usage reminder time from a configuration file;
[0132] The usage information acquisition module is used to read the user purchase resource table corresponding to the user resource identifier of the currently traversed element to obtain the time and frequency of the user's most recent use of the resource;
[0133] The third calculation module is used to calculate the difference between the usage time and the current time to obtain the interval unused time;
[0134] The reminder module 330 is further configured to remind the user that the resource has not been used for a long time when the interval non-use time reaches the use reminder time and the use frequency is greater than the use frequency threshold.
[0135] The resource reminder device applicable to electronic devices provided in the embodiments of the present disclosure can execute the resource reminder method provided in the embodiments of the present disclosure, and has the corresponding functional modules and beneficial effects of the execution method. The contents not described in detail in the embodiments of the present disclosure device can refer to the description in any method embodiment of the present disclosure.
[0136] The disclosed embodiment further provides an electronic device, including a processor and a memory; the processor calls the program or instructions stored in the memory to execute the steps of the aforementioned resource reminder method embodiments, which will not be described again here to avoid repeated description.
[0137] The embodiments of the present disclosure also provide a computer-readable storage medium, which is non-transitory and stores programs or instructions. The programs or instructions enable a computer to execute the steps of the various embodiments of the resource reminder method described above. To avoid repeated description, they are not repeated here.
[0138] The embodiments of the present disclosure also provide a computer program product, which is used to execute the steps of the above-mentioned resource reminder method embodiments.
[0139] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0140] The above description is only a specific embodiment of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A resource reminder method, characterized in that: The method comprises: Get the reminder expiration time of the resource; Traversing the elements in the cache ordered set to obtain the currently traversed element, wherein the elements in the cache ordered set are sorted according to resource expiration time; If the time difference between the resource expiration time of the currently traversed element and the current time is not greater than the reminder expiration time, perform a resource reminder based on the time difference, and continue to traverse the next element in the cache ordered set; When the time difference between the resource expiration time of the currently traversed element and the current time is greater than the reminder expiration time, the traversal of the cache ordered set is stopped.
2. The method according to claim 1, characterized in that: There are multiple reminder expiration times, and each reminder expiration time is different; The method further comprises: In a case where the time difference between the resource expiration time of the currently traversed element and the current time is not greater than the reminder expiration time, determining a first reminder expiration time from multiple reminder expiration times that has the smallest difference from the time difference and is less than the time difference; Calculate the difference between the time difference and the first reminder expiration time to obtain a first delay time; The user resource identifier of the currently traversed element is stored in a first delay queue corresponding to the first delay time.
3. The method according to claim 2, characterized in that The method further comprises: When the time length of the user resource identifier of the currently traversed element entering the first delay queue reaches the first delay time, obtaining the user resource identifier from the first delay queue; Query the user resource association table according to the user resource identifier to determine the latest expiration time of the resource subscribed by the user; When the latest expiration time is consistent with the resource expiration time, a resource reminder is performed based on the first reminder expiration time.
4. The method according to claim 3, characterized in that In the case where the latest expiration time is consistent with the resource expiration time, the method further includes: determining, from the plurality of reminder expiration times, a second reminder expiration time that has the smallest difference from the first reminder expiration time and is smaller than the first reminder expiration time; Calculating the difference between the first reminder expiration time and the second reminder expiration time to obtain a second delay time; The user resource identifier of the currently traversed element is stored in the second delay queue corresponding to the second delay time, so that when the time for the user resource identifier to enter the second delay queue reaches the second delay time and the latest expiration time of the resource subscribed by the user is consistent with the resource expiration time, a resource reminder is performed based on the second reminder expiration time.
5. The method according to claim 4, characterized in that The method further comprises: In the case where the second reminder expiration time is the minimum value among the multiple reminder expiration times, if the second reminder expiration time is not 0, using the second reminder expiration time as the third delay time; The user resource identifier of the currently traversed element is stored in the third delay queue corresponding to the third delay time, so as to provide a resource expiration reminder when the time for the user resource identifier to enter the third delay queue reaches the third delay time and the latest expiration time of the resource subscribed by the user is consistent with the resource expiration time.
6. The method according to any one of claims 3 to 5, characterized in that: The method further comprises: In the case that the latest expiration time is inconsistent with the resource expiration time, the latest expiration time and the user resource identifier are added as new elements to the cache ordered set.
7. The method according to any one of claims 1 to 5, characterized in that: The reminder expiration time for obtaining the resource includes: Get the configuration file corresponding to the resource; The configuration file is read to obtain the reminder expiration time.
8. The method according to claim 7, characterized in that The method further comprises: Obtaining a usage frequency threshold and a usage reminder time from the configuration file; Read the user purchase resource table corresponding to the user resource identifier of the currently traversed element to obtain the time of the user's most recent use of the resource and the frequency of the user's use of the resource; Calculate the difference between the usage time and the current time to obtain the interval unused time; When the interval non-use time reaches the usage reminder time and the usage frequency is greater than the usage frequency threshold, the user is reminded that the resource has not been used for a long time.
9. A resource reminder device, characterized in that: include: A first acquisition module is used to acquire a reminder expiration time corresponding to an application providing a resource; A second acquisition module is used to traverse the elements in the cache ordered set to obtain the current traversal element, wherein the elements in the cache ordered set are sorted according to resource expiration time; A reminder module, configured to, when the time difference between the resource expiration time of the currently traversed element and the current time is not greater than the reminder expiration time, perform a resource reminder based on the time difference, and continue to traverse the next element in the cache ordered set; The second acquisition module is also used to stop traversing the cache ordered set when the time difference between the resource expiration time of the currently traversed element and the current time is greater than the reminder expiration time, and to continue traversing the next element in the cache ordered set when the time difference between the resource expiration time of the currently traversed element and the current time is not greater than the reminder expiration time.
10. An electronic device, characterized in that: include: Processor and memory; The processor is used to execute the resource reminder method according to any one of claims 1 to 8 by calling the program or instruction stored in the memory.