Short link generation method and device, electronic equipment and storage medium
By routing the generated requests from user devices to target service nodes with matching performance and mapping them to target short links with matching link length and level parameters, the problem of low processing efficiency of a single server is solved, achieving efficient short link generation and resource optimization.
Patent Information
- Application Number
- CN202211126907.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-16
- Publication Date
- 2026-01-06
- Estimated Expiration
- 2042-09-16
AI Technical Summary
In existing technologies, the low efficiency of a single server in generating short links from long links leads to low processing efficiency and increases the demand for computing and storage resources.
By obtaining the generation request from the user's device, the request is routed to the target service node with matching performance based on the level parameter, mapped to the target short link with the link length matching the level parameter, and the target short link is obtained from the target service node.
It improves processing efficiency, reduces the computing and storage resources required for each service node to generate target short links, and enhances the ability to defend against attacks.
Smart Images

Figure CN115544401B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and more particularly to the field of data processing technology, specifically to a method, apparatus, electronic device, and storage medium for generating short links. Background Technology
[0002] Currently, various applications and SMS messages have byte limits. Users need long links when using applications, but using long links can easily exceed the byte limit. Similarly, when using SMS messages, using long links increases the cost of SMS messages.
[0003] In related technologies, a single server typically determines the target short link based on the target long link, which leads to low processing efficiency. Summary of the Invention
[0004] The present invention aims to at least partially solve one of the technical problems in the related art.
[0005] Therefore, the first objective of this invention is to propose a short link generation method that allocates performance-matched target service nodes to different target long links based on the level parameters of the short links to be generated. Compared with the method of a single server responding to all generation requests, this improves processing efficiency and reduces the computing and storage resources required for each service node to generate target short links.
[0006] The second objective of this invention is to propose another method for generating short links.
[0007] The third objective of this invention is to provide a short link generation device.
[0008] The fourth objective of this invention is to provide another short link generation device.
[0009] The fifth objective of this invention is to provide an electronic device.
[0010] The sixth objective of this invention is to provide a non-transitory computer-readable storage medium.
[0011] The seventh objective of this invention is to provide a computer program product.
[0012] To achieve the above objectives, a first aspect of the present invention provides a short link generation method, executed by a control node, comprising: acquiring a generation request sent by a user equipment, wherein the generation request carries a target long link for which a short link is to be generated, and a level parameter; routing the generation request to a target service node matching the level parameter according to the level parameter, so as to map the target long link to a target short link with a link length matching the level parameter according to the level parameter; if the target short link is mapped at the target service node, acquiring the target short link from the target service node; and sending a generation response carrying the target short link to the user equipment.
[0013] To achieve the above objectives, a second aspect of the present invention proposes another method for generating short links, executed by a target service node, comprising: receiving a generation request forwarded by a control node, wherein the generation request carries a target long link for which a short link is to be generated and a level parameter, and the target service node matches the level parameter; mapping the target long link to a target short link with a link length matching the level parameter according to the level parameter; and sending a generation response carrying the target short link to the user equipment through the control node.
[0014] To achieve the above objectives, a third aspect of the present invention provides a short link generation apparatus, comprising: an acquisition module, configured to acquire a generation request sent by a user equipment, wherein the generation request carries a target long link for which a short link is to be generated, and a level parameter; a routing module, configured to route the generation request to a target service node matching the level parameter according to the level parameter, so as to map the target long link to a target short link with a link length matching the level parameter according to the level parameter; a first processing module, configured to acquire the target short link from the target service node when the target short link is mapped to the target service node; and a first sending module, configured to send a generation response carrying the target short link to the user equipment.
[0015] To achieve the above objectives, a fourth aspect of the present invention provides another short link generation apparatus, comprising: a third receiving module, configured to receive a generation request forwarded by a control node, wherein the generation request carries a target long link to which a short link is to be generated and a level parameter, and the target service node matches the level parameter; a mapping module, configured to map the target long link to a target short link with a link length matching the level parameter according to the level parameter; and a third sending module, configured to send a generation response carrying the target short link to the user equipment through the control node.
[0016] To achieve the above objectives, a fifth aspect of the present invention provides an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to execute the short link generation method proposed in the first aspect of the present invention, or the short link generation method proposed in the second aspect of the present invention.
[0017] To achieve the above objectives, a sixth aspect of the present invention provides a non-transitory computer-readable storage medium, wherein the computer instructions are configured to cause the computer to execute the short link generation method proposed in the first aspect of the present invention, or the short link generation method proposed in the second aspect of the present invention.
[0018] To achieve the above objectives, a seventh aspect of the present invention provides a computer program product, wherein when the computer program is executed by a processor, it implements the short link generation method proposed in the first aspect of the present invention, or the short link generation method proposed in the second aspect of the present invention.
[0019] The technical solutions provided by the embodiments of the present invention bring at least the following beneficial effects:
[0020] By acquiring generation requests sent by user devices, which carry the target long link to be generated and a level parameter, the generation requests are routed to target service nodes matching the level parameter. This maps the target long link to a target short link with a length matching the level parameter. If the target service node has mapped the target short link, the target short link is retrieved from the target service node. Finally, a generation response carrying the target short link is sent to the user device. Therefore, by assigning performance-matched target service nodes to different target long links based on the level parameter of the short link to be generated, processing efficiency is improved compared to a single server responding to all generation requests, while reducing the computational and storage resources required for each service node to generate the target short link.
[0021] Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description
[0022] The above and / or additional aspects and advantages of the present invention will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein:
[0023] Figure 1 This is a flowchart illustrating a short link generation method provided in an embodiment of the present invention;
[0024] Figure 2 This is a flowchart illustrating another short link generation method provided in an embodiment of the present invention;
[0025] Figure 3 This is a flowchart illustrating another short link generation method provided in an embodiment of the present invention;
[0026] Figure 4 A flowchart illustrating another short link generation method provided in an embodiment of the present invention;
[0027] Figure 5 This is a flowchart of a request routing process provided in an embodiment of the present invention;
[0028] Figure 6 A flowchart of a target long link analysis provided in an embodiment of the present invention;
[0029] Figure 7 A flowchart for generating a short link index is provided in an embodiment of the present invention;
[0030] Figure 8 This is a schematic diagram of a short link generation device provided in an embodiment of the present invention;
[0031] Figure 9 This is a schematic diagram of another short link generation device provided in an embodiment of the present invention;
[0032] Figure 10 This is a block diagram of an electronic device for implementing short link generation functionality, provided as an embodiment of the present invention. Detailed Implementation
[0033] Embodiments of the present invention are described in detail below, examples of which are illustrated in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain the present invention, and should not be construed as limiting the present invention.
[0034] Currently, various applications and SMS messages have byte limits. Users need long-lived connections when using applications, but these can easily exceed byte limits. Similarly, using long-lived connections increases the cost of SMS messages. Related technologies typically rely on a single server to determine the target short-lived connection based on the target long-lived connection, leading to low processing efficiency.
[0035] To address this issue, embodiments of the present invention provide a method, apparatus, electronic device, and storage medium for generating short links. The method involves acquiring a generation request sent by a user device, wherein the generation request carries a target long link for which a short link is to be generated, and a level parameter. Based on the level parameter, the generation request is routed to a target service node matching the level parameter, thereby mapping the target long link to a target short link with a link length matching the level parameter. If the target service node maps to a target short link, the target short link is obtained from the target service node. Finally, a generation response carrying the target short link is sent to the user device. Therefore, by assigning different target service nodes to different target long links based on the level parameter of the short link to be generated, compared to a single server responding to all generation requests, processing efficiency is improved, while reducing the computational and storage resources required for each service node to generate the target short link.
[0036] The method, apparatus, electronic device, and storage medium for generating short links according to embodiments of the present invention are described below with reference to the accompanying drawings.
[0037] Figure 1 This is a flowchart illustrating a short link generation method provided in an embodiment of the present invention.
[0038] It should be noted that the short link generation method in this embodiment is executed by a short link generation device, which can be implemented by software and / or hardware, and can be configured in a user device. The user device may include, but is not limited to, wearable devices, terminal devices, etc., and this embodiment does not specifically limit the user device.
[0039] like Figure 1 As shown, this short link generation method includes the following steps:
[0040] Step 101: Obtain the generation request sent by the user device, wherein the generation request carries the target long link to be generated as a short link, and the level parameter.
[0041] In an exemplary embodiment, the target long link and level parameter are extracted from the generation request. The target long link is generally a link between a webpage and a target, while the short link is a simplified and readable version of the long link. The target long link can be a webpage address, such as a link starting with "http". The level parameter is the level of the short link to be generated, such as level 1.
[0042] Step 102: Based on the level parameter, the generated request is routed to the target service node that matches the level parameter, so as to map the target long link to the target short link whose link length matches the level parameter.
[0043] In an exemplary embodiment, the network address of the user device is extracted from the generation request; the network address is compared with the anomaly list in the firewall; if the network address is not in the anomaly list, the generation request is routed to the target service node that matches the level parameter according to the level parameter.
[0044] The short link level parameter includes 9 levels, from 1 to 9, each level corresponding to a short link length of 1 to 9, and each level corresponds to a service node. Based on the target service node corresponding to the level parameter, the generated request is routed to the target service node.
[0045] In an exemplary embodiment, an exception message sent by the target service node is received; if, based on the exception message, it is determined that the number of requests sent using network addresses in the received generation requests is greater than a threshold, the network address is added to the exception list.
[0046] In an exemplary embodiment, a rejection response is sent to the user equipment if the network address is in the exception list.
[0047] In an exemplary embodiment, the process of mapping a target long link to a target short link whose link length matches the level parameter, based on the level parameter, can be as follows: After the target service node receives the generation request, it extracts the target long link from the generation request, performs Bloom filtering on the target long link, and uses four hash functions—XXH3, City64, BKDRHash, and APHash—to filter the target long link. Bloom filtering ensures that all target long links in the generation request are in the database of the target service node. After filtering the target long links, a deduplication check is performed on the target long links. The stored mapping relationships are searched to see if a long link identical to the target long link exists. If it exists, the short link corresponding to the target long link with the existing mapping relationship is returned; otherwise, the uncached mapping relationships are searched to see if a long link identical to the target long link exists.
[0048] Step 103: If the target short link is mapped from the target service node, obtain the target short link from the target service node.
[0049] In an exemplary embodiment, the target service node is mapped to obtain a target short link, indicating that a stored mapping relationship exists for the target long link. The target short link is then obtained from the target service node according to the mapping relationship, wherein the target short link is an existing target short link.
[0050] Step 104: Send a generation response carrying the target short link to the user equipment.
[0051] In an exemplary embodiment, the user equipment receives a generation response and extracts the target short link from the generation response.
[0052] In an exemplary embodiment, an exception response is received from the target service node, indicating that all short links corresponding to the level parameters already have corresponding long links; the exception response is then forwarded to the user equipment. Upon receiving the exception response, the user equipment needs to reset the level parameters of the short links to be generated and resend the generation request.
[0053] The short link generation method provided by this invention involves: acquiring a generation request sent by a user device, wherein the generation request carries a target long link to which a short link is to be generated, and a level parameter; routing the generation request to a target service node matching the level parameter, so as to map the target long link to a target short link with a link length matching the level parameter; if the target service node maps to a target short link, retrieving the target short link from the target service node; and sending a generation response carrying the target short link to the user device. Thus, by allocating performance-matched target service nodes to different target long links according to the level parameter of the short link to be generated, compared to a single server responding to all generation requests, processing efficiency is improved, while reducing the computational and storage resources required for each service node to generate the target short link.
[0054] To address potential attacks that may occur when a user device sends a generation request, this embodiment provides an alternative method for generating short links, thereby improving the ability to defend against attacks. Figure 2 This is a flowchart illustrating another short link generation method provided in an embodiment of the present invention.
[0055] like Figure 2 As shown, the short link generation method may include the following steps:
[0056] Step 201: Obtain the list of exceptions for obtaining network addresses.
[0057] In an exemplary embodiment, the process of obtaining a historical list of network addresses may be as follows: receiving exception messages sent by each service node; if, based on the exception messages, it is determined that the number of requests sent using a network address in the received generation requests is greater than a threshold, then the network address is added to the exception list.
[0058] Furthermore, before adding a network address to the anomaly list, the network addresses indicated by the anomaly messages can be grouped and counted. This count indicates the number of anomaly messages associated with that network address, and the count is incremented by one each time an anomaly message is added. A time-related decay factor is applied to the count; after a certain period, the count value decreases to half its original value. If the count value is greater than half its original value after a certain period, it is determined to be consistent with attack behavior, and the network address is added to the historical anomaly list.
[0059] Step 202: Obtain the generation request sent by the user device, wherein the generation request carries the target long link to be generated and the level parameter.
[0060] Step 203: If the network address is on the exception list, send a rejection response to the user equipment.
[0061] In an exemplary embodiment, the network address is compared with an exception list. If the network address is in the exception list, a rejection response is sent to the user equipment, and the processing of the request generated by the user equipment ends. If the network address is not in the exception list, step 205 is executed.
[0062] Step 204: If the network address is not in the exception list, the generated request is routed to the target service node that matches the level parameter, so as to map the target long link to the target short link whose link length matches the level parameter.
[0063] In an exemplary embodiment, after routing the generation request to a target service node that matches the level parameter, the target service node may periodically or non-periodically perform the following steps: extracting the network address of the user device from the generation request; counting the number of requests sent using the network address among the received generation requests; and if it is determined that the number of requests is greater than a threshold, sending an exception message to the control node so that the control node adds the network address to the exception list, thereby updating the exception list.
[0064] Step 205: If the target short link is mapped from the target service node, obtain the target short link from the target service node.
[0065] Step 206: Send a generation response carrying the target short link to the user equipment.
[0066] It should be noted that detailed descriptions of steps 202, 204, 205, and 206 can be found in other embodiments of this invention, and will not be described in detail here.
[0067] In summary, the system improves its attack defense capabilities by obtaining an anomaly list of network addresses; acquiring generation requests sent by user devices, which carry the target long link to be generated, the network address, and a level parameter; sending a rejection response to the user device if the network address is in the anomaly list; routing the generation request to a target service node matching the level parameter, based on the level parameter, to map the target long link to a target short link with a length matching the level parameter; obtaining the target short link from the target service node if it has been mapped; and sending a generation response carrying the target short link to the user device. By comparing the network address in the generation request with a historical anomaly list, and rejecting the generation request if the network address exists in the historical anomaly list, the system enhances its attack defense capabilities.
[0068] To implement the aforementioned short link generation method, this embodiment provides another short link generation method based on the target service node. Figure 3 This is a flowchart illustrating another short link generation method provided in an embodiment of the present invention.
[0069] like Figure 3 As shown, the short link generation method may include the following steps:
[0070] Step 301: Receive the generation request forwarded by the control node, wherein the generation request carries the target long link to be generated and the level parameter, and the target service node matches the level parameter.
[0071] In an exemplary embodiment, the short link generation device receives a generation request forwarded by the control node and extracts the target long link and level parameters from the generation request.
[0072] It should be noted that the target long link in the generated request is a target long link whose link length and level parameter did not match in the mapping relationship in the above embodiment, and the generated request has been routed to the target service node according to the boundary parameter.
[0073] Step 302: Based on the level parameter, map the target long link to the target short link whose link length matches the level parameter.
[0074] In an exemplary embodiment, before mapping a target long link to a target short link whose link length matches the level parameter according to the level parameter, the method further includes: querying whether the target long link has a mapped short link in the cached mapping relationship; if no mapped short link is found, mapping the target long link to a target short link whose link length matches the level parameter according to the level parameter; and storing the mapping relationship between the target long link and the target short link.
[0075] Specifically, if a short link that maps to the target long link is found, the found short link will be used as the target short link.
[0076] In an exemplary embodiment, the network address of the user device is extracted from the generation request; the number of requests sent using the network address is counted among the received generation requests; if the number of requests is determined to be greater than a threshold, an exception message is sent to the control node so that the control node adds the network address to the exception list.
[0077] In an exemplary embodiment, an unused short link index is queried in the short link index library; if an unused short link index is found in the short link index library, the target long link is mapped to a target short link whose link length matches the level parameter according to the level parameter; the unused short link index is used as the index of the target short link, and the unused short link index is updated to be used.
[0078] If all short link indexes in the short link index library are already in use, an exception response is sent to the user equipment through the control node.
[0079] In this embodiment, a distributed key generator is used to generate short link indexes for each service node. Each short link index is unique; for example, the short link index range corresponding to level parameter 1 is 0-63. Therefore, base-64 encoding is used, consisting of characters 0-9, az, AZ, and +-, thereby converting the short link index into the target short link.
[0080] Step 303: Send a generation response carrying the target short link to the user equipment through the control node.
[0081] In an exemplary embodiment, after obtaining the target short link, a generation response is sent to the user device, and the user device extracts the target short link from the generation response. Specifically, if the target long link is a webpage address starting with "http", the generation response is a webpage address starting with "http" combined with the target short link.
[0082] The short link generation method provided by this invention involves receiving a generation request forwarded by a control node. The generation request carries a target long link to which a short link is to be generated and a level parameter, with the target service node matching the level parameter. Based on the level parameter, the target long link is mapped to a target short link with a link length matching the level parameter. The control node then sends a generation response carrying the target short link to the user equipment. Therefore, by mapping the target long link to a target short link with a link length matching the level parameter, the method improves processing efficiency compared to a single server responding to all generation requests, while reducing the computational and storage resources required for each service node to generate the target short link.
[0083] For example, such as Figure 4 As shown, this invention provides another method for generating short links, which includes the following steps:
[0084] Step S1, level routing, which routes the request to generate the short link to the target service node.
[0085] Among them, such as Figure 5 As shown, level routing routes the generated request to the processing cluster (target service node) based on the level parameter attached to the generated request.
[0086] Before step S1, the generation request is processed according to the firewall's blacklist. If the target long link in the request to generate a short link (generation request) is in the blacklist, the generation request is rejected.
[0087] Step S2, link analysis, which involves analyzing the target long links.
[0088] like Figure 6 As shown, the process of the short link generation device executing step S2 can be as follows: Perform a Bloom filter test on the original link (target long link); if the filter fails, directly obtain the target short link sequence number (short link index); if the filter passes, perform precise deduplication on the original link (target long link). In the mapping relationship, query whether there is a long link identical to the original link (target long link). If there is no duplicate, directly obtain the target short link sequence number (short link index); if the original link (target long link) is duplicated, perform attack analysis on the original link (target long link). Count the number of groups based on the address of the generation request, and apply a time-related decay factor to the count, i.e., reduce it to half its original value at regular intervals. Finally, if the count exceeds a threshold, it is determined to be consistent with attack behavior, and the generation request is added to the firewall blacklist; if it is not consistent with attack behavior, return the existing short link sequence number (send a generation response carrying the target short link to the user equipment).
[0089] Step S3, short link number generation, that is, determining the mapping relationship between target long links and target short links, and generating short link indexes.
[0090] like Figure 7 As shown, the process of the short link generation device executing step S3 can be as follows: The distributed number generator generates a unique short link sequence number (short link index) corresponding to the original link (target long link) based on the input level (level parameter) and the original link (target long link). Then, a mapping relationship is constructed based on the input level (level parameter) and the original link (target long link). If the generated short link sequence number (short link index) does not meet the uniqueness requirement, the distributed number generator regenerates the short link sequence number (short link index).
[0091] Step S4: Use an encoder to convert the short link index into the target short link.
[0092] The short link index is converted into the target short link by using base-64 encoding, which consists of characters 0-9, az, AZ, and +-.
[0093] In summary, this method involves routing requests for generating short links to target service nodes; analyzing target long links; determining the mapping relationship between target long links and target short links to generate a short link index; and using an encoder to convert the short link index into target short links. Therefore, based on the level parameters of the short links to be generated, performance-matched target service nodes are assigned to different target long links. Compared to a single server responding to all generation requests, this improves processing efficiency while reducing the computational and storage resources required for each service node to generate target short links.
[0094] To achieve the above embodiments, the present invention also proposes a short link generation device.
[0095] Figure 8 This is a schematic diagram of a short link generation device provided in an embodiment of the present invention.
[0096] like Figure 8 As shown, the short link generation device 800 includes: an acquisition module 810, a routing module 820, a first processing module 830, and a first sending module 840.
[0097] The acquisition module 810 is used to acquire a generation request sent by the user equipment, wherein the generation request carries the target long link to be generated as a short link, and a level parameter.
[0098] The routing module 820 is used to route the generated request to a target service node that matches the level parameter according to the level parameter, so as to map the target long link to a target short link whose link length matches the level parameter according to the level parameter.
[0099] The first processing module 830 is used to obtain the target short link from the target service node when the target short link is mapped to the target service node.
[0100] The first sending module 840 is used to send a generation response carrying the target short link to the user equipment.
[0101] As one possible implementation of this invention, the routing module 820 is specifically configured to extract the network address of the user device from the generation request; compare the network address with an anomaly list in the firewall; and, if the network address is not in the anomaly list, route the generation request to a target service node matching the level parameter according to the level parameter.
[0102] As a possible implementation of this invention, the device 800 further includes: a receiving module and a second processing module; wherein, the receiving module is configured to receive an exception message sent by the target service node; and the second processing module is configured to add the network address to the exception list if, based on the exception message, it is determined that the number of requests sent using the network address in the received generation requests is greater than a threshold.
[0103] As one possible implementation of this invention, the apparatus 800 further includes: a second sending module; wherein the second sending module is configured to send a rejection response to the user equipment when the network address is in the exception list.
[0104] As a possible implementation of this invention, the device 800 further includes: a second receiving module and a forwarding module; wherein the second receiving module is used to receive an abnormal response sent by the target service node, wherein the abnormal response is used to indicate that all short links corresponding to the level parameters have corresponding long links; the forwarding module is used to forward the abnormal response to the user equipment.
[0105] It should be noted that the foregoing explanation of the embodiment of the short link generation method also applies to the short link generation device of this embodiment, and will not be repeated here.
[0106] The short link generation apparatus of this invention obtains a generation request sent by a user equipment, wherein the generation request carries a target long link to which a short link is to be generated, and a level parameter; according to the level parameter, the generation request is routed to a target service node matching the level parameter, so as to map the target long link to a target short link with a link length matching the level parameter; if the target service node maps to a target short link, the target short link is obtained from the target service node; and a generation response carrying the target short link is sent to the user equipment. Thus, by allocating performance-matched target service nodes to different target long links according to the level parameter of the short link to be generated, compared with the method of a single server responding to all generation requests, processing efficiency is improved, while reducing the computing and storage resources required for each service node to generate the target short link.
[0107] like Figure 9As shown, this embodiment of the invention also provides a possible implementation of a short link generation device. The short link generation device 900 includes: a third receiving module 910, a mapping module 920, and a third sending module 930.
[0108] In this embodiment of the invention, the third receiving module 910 is used to receive a generation request forwarded by the control node, wherein the generation request carries a target long link to be generated and a level parameter, and the target service node matches the level parameter.
[0109] The mapping module 920 is used to map the target long link to a target short link whose link length matches the level parameter according to the level parameter.
[0110] The third sending module 930 is used to send a generation response carrying the target short link to the user equipment through the control node.
[0111] As a possible implementation of this invention, the mapping module 920 is further configured to query whether the target long link has a mapped short link in the cached mapping relationship; if no mapped short link is found for the target long link, the target long link is mapped to a target short link with a link length matching the level parameter according to the level parameter; and the mapping relationship between the target long link and the target short link is stored.
[0112] As a possible implementation of this invention, the device 900 further includes: a third processing module; wherein the third processing module is configured to, when a short link mapped to the target long link is found, use the found short link as the target short link.
[0113] As a possible implementation of this invention, the device 900 further includes: an extraction module, a statistics module, and a fourth sending module; wherein, the extraction module is used to extract the network address of the user equipment from the generation request; the statistics module is used to count the number of requests sent using the network address among the received generation requests; and the fourth sending module is used to send an exception message to the control node when it is determined that the number of requests is greater than a threshold, so that the control node adds the network address to the exception list.
[0114] As one possible implementation of this invention, the mapping module 920 is specifically used to query unused short link indexes in the short link index library; if an unused short link index is found in the short link index library, then according to the level parameter, the target long link is mapped to a target short link whose link length matches the level parameter; the unused short link index is used as the index of the target short link, and the unused short link index is updated to be used.
[0115] As a possible implementation of this invention, the device 900 further includes: a fifth sending module; wherein the fifth sending module is used to send an abnormal response to the user equipment through the control node when all short link indexes in the short link index library are occupied.
[0116] It should be noted that the foregoing explanation of the embodiment of the short link generation method also applies to the short link generation device of this embodiment, and will not be repeated here.
[0117] The short link generation apparatus provided by this invention receives a generation request forwarded by a control node. The generation request carries a target long link to which a short link is to be generated and a level parameter, and the target service node matches the level parameter. Based on the level parameter, the target long link is mapped to a target short link with a link length matching the level parameter. The control node then sends a generation response carrying the target short link to the user equipment. Therefore, by mapping the target long link to a target short link with a link length matching the level parameter, the processing efficiency is improved compared to a single server responding to all generation requests, while simultaneously reducing the computational and storage resources required for each service node to generate the target short link.
[0118] To implement the above embodiments, the present invention also provides an electronic device, a readable storage medium, and a computer program product.
[0119] The electronic device includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the short link generation method proposed in the first aspect embodiment of the present invention as described above, or the short link generation method proposed in the second aspect embodiment of the present invention.
[0120] As an example, Figure 10 A block diagram of an electronic device for implementing short link generation functionality is provided in an embodiment of the present invention, such as... Figure 10 As shown, the aforementioned electronic device 1000 may further include:
[0121] The memory 1010 and the processor 1020 are connected by a bus 1030, which connects different components (including the memory 1010 and the processor 1020). The memory 1010 stores a computer program. When the processor 1020 executes the program, it implements the short link generation method proposed in the first aspect embodiment of the present invention, or the short link generation method proposed in the second aspect embodiment of the present invention.
[0122] Bus 1030 represents one or more of several bus architectures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of the various bus architectures. For example, these architectures include, but are not limited to, the Industry Standard Architecture (ISA) bus, the Micro Channel Architecture (MAC) bus, the Enhanced ISA bus, the Video Electronics Standards Association (VESA) local bus, and the Peripheral Component Interconnect (PCI) bus.
[0123] Electronic device 1000 typically includes a variety of computer-readable media. These media can be any available media that can be accessed by electronic device 1000, including volatile and non-volatile media, removable and non-removable media.
[0124] The memory 1010 may also include computer system readable media in the form of volatile memory, such as random access memory (RAM) 1040 and / or cache memory 1050. The electronic device 1000 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 1060 may be used to read and write non-removable, non-volatile magnetic media (…). Figure 10 Not shown; usually referred to as a "hard drive"). Although Figure 10 Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk") and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 1030 via one or more data media interfaces. Memory 1010 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of the embodiments of the present invention.
[0125] A program / utility 1080 having a set (at least one) of program modules 1070 may be stored, for example, in memory 1010. Such program modules 1070 include—but are not limited to—an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. Program modules 1070 typically perform the functions and / or methods described in the embodiments of the present invention.
[0126] Electronic device 1000 can also communicate with one or more external devices 1090 (e.g., keyboard, pointing device, display 1091, etc.), and with one or more devices that enable a user to interact with the electronic device 1000, and / or with any device that enables the electronic device 1000 to communicate with one or more other computing devices (e.g., network card, modem, etc.). This communication can be performed via input / output (I / O) interface 1092. Furthermore, electronic device 1000 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 1093. Figure 10 As shown, network adapter 1093 communicates with other modules of electronic device 1000 via bus 1030. It should be understood that, although... Figure 10 As not shown, other hardware and / or software modules may be used in conjunction with the electronic device 1000, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0127] The processor 1020 performs various functional applications and data processing by running programs stored in the memory 1010.
[0128] It should be noted that the implementation process and technical principles of the electronic device in this embodiment are explained in the foregoing description of the short link generation method of this invention, and will not be repeated here.
[0129] The electronic device provided in this embodiment of the invention obtains a generation request sent by a user equipment, wherein the generation request carries a target long link to be generated as a short link, and a level parameter; according to the level parameter, the generation request is routed to a target service node matching the level parameter, so as to map the target long link to a target short link with a link length matching the level parameter; if the target service node maps to a target short link, the target short link is obtained from the target service node; and a generation response carrying the target short link is sent to the user equipment. Thus, by allocating performance-matched target service nodes to different target long links according to the level parameter of the short link to be generated, compared with the method of a single server responding to all generation requests, processing efficiency is improved, while reducing the computing and storage resources required for each service node to generate the target short link.
[0130] To implement the above embodiments, the present invention also proposes a non-transitory computer-readable storage medium, wherein when the instructions in the computer-readable storage medium are executed by the processor of an electronic device, the electronic device is able to execute the short link generation method proposed in the first aspect embodiment of the present invention as described above, or the short link generation method proposed in the second aspect embodiment of the present invention.
[0131] To implement the above embodiments, the present invention also provides a computer program product, which, when executed by the processor of an electronic device, enables the electronic device to execute the short link generation method proposed in the first aspect embodiment of the present invention, or the short link generation method proposed in the second aspect embodiment of the present invention.
[0132] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0133] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this invention, "a plurality of" means at least two, such as two, three, etc., unless otherwise explicitly specified.
[0134] Any process or method description in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing custom logic functions or processes, and the scope of preferred embodiments of the invention includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as should be understood by those skilled in the art to which embodiments of the invention pertain.
[0135] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include: an electrical connection having one or more wires (electronic device), a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Alternatively, the computer-readable medium may be paper or other suitable media on which the program can be printed, since the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in a computer memory.
[0136] It should be understood that various parts of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware as in another embodiment, it can be implemented using any of the following techniques known in the art, or a combination thereof: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0137] Those skilled in the art will understand that all or part of the steps of the methods described in the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it includes one or a combination of the steps of the method embodiments.
[0138] Furthermore, the functional units in the various embodiments of the present invention can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.
[0139] The storage medium mentioned above can be a read-only memory, a disk, or an optical disk, etc. Although embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of the present invention.
Claims
1. A short link generation method, characterized by, The method is performed by a control node and comprises the following steps: receiving a generation request sent by a user equipment, wherein the generation request carries a target long link to be generated into a short link and a level parameter; routing the generation request to a target service node matched with the level parameter according to the level parameter, so as to map the target long link into a target short link with a link length matched with the level parameter according to the level parameter; in the case that the target short link is mapped by the target service node, obtaining the target short link from the target service node; sending a generation response carrying the target short link to the user equipment.
2. The method of claim 1, wherein, The routing of the generation request to the target service node matched with the level parameter according to the level parameter comprises: extracting a network address of the user equipment from the generation request; comparing the network address with an abnormal list in a firewall; in the case that the network address is not in the abnormal list, routing the generation request to the target service node matched with the level parameter according to the level parameter.
3. The method of claim 2, wherein, The method further comprises: receiving an abnormal message sent by the target service node; if the number of requests sent by the network address in the received generation requests is greater than a threshold value according to the abnormal message, adding the network address into the abnormal list.
4. The method of claim 2, wherein, The method further comprises: in the case that the network address is in the abnormal list, sending a rejection response to the user equipment.
5. The method according to any one of claims 1 to 4, characterized in that, The method further comprises: receiving an abnormal response sent by the target service node, wherein the abnormal response is used to indicate that short links corresponding to the level parameter all have corresponding long links; forwarding the abnormal response to the user equipment.
6. A short link generation method characterized by comprising: The method is performed by a target service node and comprises the following steps: receiving a generation request forwarded by a control node, wherein the generation request carries a target long link to be generated into a short link and a level parameter, and the target service node is matched with the level parameter; mapping the target long link into a target short link with a link length matched with the level parameter according to the level parameter; sending a generation response carrying the target short link to a user equipment through the control node.
7. The method of claim 6, wherein, Before the mapping of the target long link into the target short link with the link length matched with the level parameter according to the level parameter, the method further comprises: querying whether the target long link has a mapped short link in a cache-stored mapping relationship; in the case that no mapped short link of the target long link is queried, mapping the target long link into a target short link with a link length matched with the level parameter according to the level parameter; storing a mapping relationship between the target long link and the target short link.
8. The method of claim 7, wherein, The method further comprises: in the case that a mapped short link of the target long link is queried, taking the queried short link as the target short link.
9. The method of claim 6, wherein, The method further comprises: extracting a network address of the user equipment from the generation request; counting the number of requests sent by the network address in the received generation requests; determine that the number of requests is greater than a threshold, and send an exception message to the control node to cause the control node to add the network address to an exception list.
10. The method according to any one of claims 6-9, characterized in that, The target long link is mapped into a target short link with a link length matching the level parameter according to the level parameter, including: querying an unoccupied short link index in a short link index library; If an unoccupied short link index is queried in the short link index library, the target long link is mapped into a target short link with a link length matching the level parameter according to the level parameter; The unoccupied short link index is taken as an index of the target short link, and the unoccupied short link index is updated as occupied.
11. The method of claim 10, wherein, The method further includes: If all short link indexes in the short link index library are occupied, an exception response is sent to the user equipment by the control node.
12. A short link generating apparatus, characterized by comprising: including: The acquisition module is configured to acquire a generation request sent by a user equipment, wherein the generation request carries a target long link to be generated and a level parameter; The routing module is configured to route the generation request to a target service node matching the level parameter according to the level parameter, to map the target long link into a target short link with a link length matching the level parameter according to the level parameter; The first processing module is configured to acquire the target short link from the target service node if the target short link is mapped in the target service node; The first sending module is configured to send a generation response carrying the target short link to the user equipment.
13. The apparatus of claim 12, wherein, The routing module is specifically configured to, extract the network address of the user equipment from the generation request; compare the network address with an exception list in a firewall; route the generation request to a target service node matching the level parameter according to the level parameter if the network address is not in the exception list.
14. The apparatus of claim 13, wherein, The device further includes a receiving module and a second processing module; The receiving module is configured to receive an exception message sent by the target service node; The second processing module is configured to add the network address to the exception list if it is determined according to the exception message that the number of requests sent by the network address in the generation request received is greater than a threshold.
15. The apparatus of claim 13, wherein, The device further includes a second sending module; The second sending module is configured to send a rejection response to the user equipment if the network address is in the exception list.
16. The device of any one of claims 12-15, wherein, The device further includes a second receiving module and a forwarding module; The second receiving module is configured to receive an exception response sent by the target service node, wherein the exception response is used to indicate that short links corresponding to the level parameter all have corresponding long links; The forwarding module is configured to forward the exception response to the user equipment.
17. A short link generating apparatus, characterized by comprising: including: The third receiving module is configured to receive a generation request forwarded by a control node, wherein the generation request carries a target long link to be generated and a level parameter, and a target service node matches the level parameter; The mapping module is configured to map the target long link into a target short link with a link length matching the level parameter according to the level parameter. The third sending module is configured to send a generation response carrying the target short link to a user equipment through the control node.
18. The apparatus of claim 17, wherein, The mapping module is further configured to, query whether the target long link has a mapped short link in the stored mapping relationship; map the target long link into a target short link with a link length matching the level parameter according to the level parameter in a case where no mapped short link of the target long link is queried; store a mapping relationship between the target long link and the target short link.
19. The apparatus of claim 18, wherein, The apparatus further comprises a third processing module. The third processing module is configured to take the queried short link as the target short link in a case where the mapped short link of the target long link is queried.
20. The apparatus of claim 17, wherein, The apparatus further comprises an extracting module, a statistical module and a fourth sending module. The extracting module is configured to extract a network address of the user equipment from the generation request. The statistical module is configured to count a number of requests sent by using the network address in the received generation requests. The fourth sending module is configured to send an abnormal message to the control node to make the control node add the network address to an abnormal list in a case where the number of requests is greater than a threshold.
21. The apparatus of any of claims 17-20, wherein, The mapping module is specifically configured to, query an unoccupied short link index in a short link index library; map the target long link into a target short link with a link length matching the level parameter according to the level parameter in a case where an unoccupied short link index is queried in the short link index library; take the unoccupied short link index as an index of the target short link, and update the unoccupied short link index as occupied.
22. The apparatus of claim 21, wherein, The apparatus further comprises a fifth sending module. The fifth sending module is configured to send an abnormal response to a user equipment through the control node in a case where all short link indexes in the short link index library are occupied. 23.An electronic device comprising: at least one processor; and a memory connected with the at least one processor in communication;wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-5, or perform the method of any one of claims 6-11.
24. A non-transitory computer readable storage medium having stored thereon computer instructions, wherein, The computer instructions are used to make the computer perform the method of any one of claims 1-5, or perform the method of any one of claims 6-11. 25.A computer program product comprising a computer program which, when executed by a processor, implements the method of any one of claims 1-5, or performs the method of any one of claims 6-11.
Citation Information
Patent Citations
Short link generation and analysis method and device
CN111651695A
Service serial number generation method, number sender component, equipment and storage medium
CN113722323A