Short link generation method and device, electronic equipment, and storage medium
Patent Information
- Application Number
- CN202210262256.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-16
- Publication Date
- 2026-10-27
- Estimated Expiration
- 2042-03-16
AI Technical Summary
当前生成短链接的方式通常会出现同一个长连接对应多个不同的短链接的冲突现象,从而使得访问者访问短链接时发生访问错误
[0014]根据本申请实施例的一个方面,提供了一种计算机程序产品或计算机程序,该计算机程序产品或计算机程序包括计算机指令,该计算机指令存储在计算机可读存储介质中。计算机设备的处理器从计算机可读存储介质读取该计算机指令,处理器执行该计算机指令,使得该计算机设备执行上述各种可选实施例中提供的短链接的生成方法。
Smart Images

Figure CN116796099B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of information prompting technology, and more specifically, to methods, apparatus, electronic devices, and storage media for generating short links. Background Technology
[0002] Shortened links are unique strings that convert long links into concise strings through programmatic calculation. By converting long links to short links, character counts are saved during storage and transmission, and sensitive request parameters are hidden. Users can obtain the corresponding long link through shortened links and correctly navigate to the resource linked by the long link. In interactive, notification, and marketing scenarios that require links, there are often limitations on the length of text strings; converting long links to short links plays a crucial role in these situations. However, current methods of generating short links often result in conflicts where the same long link corresponds to multiple different short links, leading to access errors when visitors try to access the short links. Summary of the Invention
[0003] To address the aforementioned technical problems, embodiments of this application provide a method for generating short links, an apparatus for generating short links, an electronic device, and a computer-readable storage medium, which can avoid conflicts where the same long link corresponds to multiple different short links.
[0004] Other features and advantages of this application will become apparent from the following detailed description, or may be learned in part from practice of this application.
[0005] According to one aspect of the embodiments of this application, a method for generating short links is provided, comprising: receiving a short link generation request, the short link generation request including a long link to be entered; if the long link to be entered is not a primary key contained in a first data table, then responding to the short link generation request to generate a short link corresponding to the long link to be entered, wherein the first data table is used to store the entered long links and corresponding short links in a key-value pair storage method, and the entered long links are used as primary keys; and storing the long link to be entered and the corresponding short link in the first data table.
[0006] According to one aspect of the embodiments of this application, a short link generation apparatus is provided, comprising: a first receiving module, configured to receive a short link generation request, the short link generation request including a long link to be entered; a short link generation module, configured to generate a short link corresponding to the long link to be entered in response to the short link generation request if the long link to be entered is not a primary key contained in a first data table, wherein the first data table is configured to store the entered long links and corresponding short links in a key-value pair storage method, and the entered long links are used as primary keys; and a first storage module, configured to store the long link to be entered and the corresponding short link in the first data table.
[0007] According to one aspect of the embodiments of this application, the short link generation device provided in this embodiment further includes a second storage module, wherein the second storage module is used to store the long link to be entered and the short link corresponding to the long link to be entered in a second data table in a key-value pair storage method, and uses the short link corresponding to the long link to be entered as the primary key.
[0008] According to one aspect of the embodiments of this application, the short link generation apparatus provided in this embodiment further includes a second receiving module and a redirection module, wherein the receiving module is used to receive a short link conversion request, the short link conversion request including a short link to be converted; the redirection module is used to obtain the long link corresponding to the short link to be converted based on the primary key if the short link to be converted is found to be a primary key contained in the second data table, and redirect to the long link corresponding to the short link to be converted.
[0009] According to one aspect of the embodiments of this application, the second storage module includes an acquisition unit and a storage unit, wherein the acquisition unit is used to acquire the MD5 value of the long link to be entered; and the storage unit is used to store the MD5 value in a second data table.
[0010] According to one aspect of the embodiments of this application, the short link generation module includes a calculation unit and a conversion unit, wherein the calculation unit is used to perform hash calculation on the long link to be entered to obtain the hash value corresponding to the long link to be entered; the conversion unit is used to convert the hash value into hexadecimal characters and use the characters as the short link corresponding to the long link to be entered.
[0011] According to one aspect of the embodiments of this application, the short link generation device provided in this embodiment further includes an accumulation module and a sending module, wherein the accumulation module is used to increment the cumulative request conversion count of the short link to be converted within a preset time period based on the received short link conversion request; the sending module is used to, if the obtained cumulative request conversion count exceeds a preset threshold, treat the short link to be converted as an abnormal request short link and send abnormal request information to the management platform, the abnormal request information including the abnormal request short link.
[0012] According to one aspect of the embodiments of this application, an electronic device is provided, including a processor and a memory, wherein computer-readable instructions are stored in the memory, and when the computer-readable instructions are executed by the processor, the method for generating short links as described above is implemented.
[0013] According to one aspect of the embodiments of this application, a computer-readable storage medium is provided, on which computer-readable instructions are stored, which, when executed by a computer's processor, cause the computer to perform the short link generation method provided above.
[0014] According to one aspect of the embodiments of this application, a computer program product or computer program is provided, the computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, causing the computer device to perform the short link generation method provided in the various alternative embodiments described above.
[0015] In the technical solution provided by the embodiments of this application, by storing the mapping relationship between long links and corresponding short links in a first data table, and using the long link as the primary key in the data table, it is possible to quickly determine whether the first data table stores a short link corresponding to the long link to be entered. Thus, before the short link is generated, the conflict between two or more different short links corresponding to the same long link can be avoided, thereby preventing access errors when visitors access short links.
[0016] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description
[0017] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application. It is obvious that the drawings described below are merely some embodiments of this application, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort. In the drawings:
[0018] Figure 1 This is a schematic diagram illustrating the implementation environment of the present invention according to an exemplary embodiment;
[0019] Figure 2 This is a flowchart illustrating a method for generating short links, as shown in an exemplary embodiment of this application;
[0020] Figure 3 This is a flowchart illustrating a method for generating short links according to an exemplary embodiment of this application;
[0021] Figure 4 This is a schematic diagram of the structure of the first data table shown in an exemplary embodiment of this application;
[0022] Figure 5 This is a schematic diagram illustrating the structure of the SSD file in the first data table according to an exemplary embodiment of this application;
[0023] Figure 6 yes Figure 2 Step S103 in the illustrated embodiment is shown in a flowchart of an exemplary embodiment;
[0024] Figure 7 yes Figure 2 Step S102 in the illustrated embodiment is a flowchart of an exemplary embodiment;
[0025] Figure 8 yes Figure 2 Step S102 in the illustrated embodiment is shown in a flowchart of an exemplary embodiment;
[0026] Figure 9 yes Figure 2 Step S103 in the illustrated embodiment is a process of an exemplary embodiment;
[0027] Figure 10 This is a schematic diagram illustrating the structure of the SSD file in the second data table according to an exemplary embodiment of this application;
[0028] Figure 11 This is a schematic diagram illustrating a method for generating short links according to an exemplary embodiment of this application;
[0029] Figure 12 Is Figure 2 A flowchart of the short link generation method proposed in the illustrated embodiment;
[0030] Figure 13 Is Figure 2 A flowchart of the short link generation method proposed in the illustrated embodiment;
[0031] Figure 14 Is Figure 2 A flowchart of the short link generation method proposed in the illustrated embodiment;
[0032] Figure 15 This is a block diagram illustrating a short link generation apparatus according to an exemplary embodiment of this application;
[0033] Figure 16 A schematic diagram of the structure of a computer system suitable for implementing the electronic device of the present application is shown. Detailed Implementation
[0034] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0035] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0036] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all content and operations / steps, nor do they necessarily have to be performed in the described order. For example, some operations / steps can be broken down, while others can be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.
[0037] It should also be noted that "multiple" as mentioned in this application refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.
[0038] Figure 1 This is a schematic diagram illustrating an implementation environment related to the present invention according to an exemplary embodiment. The implementation environment related to the present invention can be applied to various scenarios such as cloud technology, artificial intelligence, smart transportation, and assisted driving. Figure 1 As shown, the implementation environment involved in this invention includes at least a user-used terminal 110 and a server 130. Data interaction between the terminal 110 and the server 130 is achieved via the Internet.
[0039] Terminal 110 can be a smartphone, tablet, PC (Personal Computer), smart voice interaction device, smart home appliance, vehicle terminal, or any other electronic device capable of running applications; no restrictions are imposed here. Server 130 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms; no restrictions are imposed here either.
[0040] For example, terminal 110 is used to send a short link generation request to server 130. Server 130 is used to generate a short link corresponding to the long link to be entered if the long link to be entered is not a primary key contained in the first data table. The first data table is used to store the entered long links and their corresponding short links in a key-value pair storage method, and the entered long links are used as primary keys. The long link to be entered and its corresponding short link are stored in the first data table.
[0041] Shortened links are created by converting long Uniform Resource Locators (URLs) into shorter URL strings through programmatic calculations, thus saving character count. Current methods for generating shortened links take the original long link as input and use a hash algorithm to generate a corresponding short link. When a user attempts to resolve the short link, it is retrieved from the link storage unit, and the original URL is returned for address redirection.
[0042] However, the inventors of this application have discovered through long-term research that although existing technologies can generate short links corresponding to the original long links, if the same long link requests the generation of short links multiple times, the existing short link generation methods will inevitably result in different short links being generated each time. This leads to the same long link corresponding to multiple different short links, causing short link conflicts and resulting in access errors when visitors access short links.
[0043] To address at least the aforementioned problems in the prior art, embodiments of this application propose a method for generating short links, a device for generating short links, an electronic device, and a computer-readable storage medium, which will be described in detail below. These embodiments can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, smart transportation, and assisted driving.
[0044] Please see Figure 2 , Figure 2 This is a flowchart illustrating a method for generating short links, as shown in an exemplary embodiment of this application. Figure 2 As shown, the method for generating short links provided in this embodiment includes steps S101-S103, which are described in detail below:
[0045] Step S101: Receive short link generation request.
[0046] In this embodiment, the short link generation request includes the long link to be entered, and the received short link generation request is used to request the generation of the short link corresponding to the long link to be entered.
[0047] Step S102: If the long link to be entered is not a primary key contained in the first data table, then respond to the short link generation request and generate the short link corresponding to the long link to be entered.
[0048] In this embodiment, the first data table is used to store the entered long links and corresponding short links in a key-value pair storage method, and the entered long links are used as the primary key.
[0049] In this embodiment, data is stored in a data table using key-value pairs, allowing you to retrieve a corresponding value based on a key. For example, in typical object-oriented programming, you often use `Form.Enable = True` or `False`, where `Form.Enable` is a primary key (or key value) in the data table, and `True` or `False` is the value (or non-primary key) corresponding to `Form.Enable` in the data table. You can retrieve the value corresponding to `Form.Enable`, i.e., `True` or `False`, from the corresponding data table using the primary key `Form.Enable`.
[0050] In this embodiment, the recorded long links and their corresponding short links are stored in a first data table using a key-value pair storage method. This means that the first data table is used to store the mapping relationship from the recorded long links to the corresponding short links. Therefore, the recorded long links can be used as the primary key to obtain the short links corresponding to the recorded long links.
[0051] In fact, in existing technologies, short link systems (or short link servers) typically store the mapping relationship between long links and their corresponding short links in a single data table. Furthermore, to facilitate the conversion request from long link to short link, the short link corresponding to the long link is set as the primary key in this data table. This storage method has many drawbacks. For example, storing the mapping relationship between long links and their corresponding short links in a single data table during short link generation, and setting the short link corresponding to the long link as the primary key, makes it impossible to handle conflicts where the same long link corresponds to two or more different short links. This is because it's impossible to determine whether the data table with the short link as the primary key contains the long link to be entered.
[0052] In this embodiment, if the long link to be entered is not a primary key contained in the first data table, it indicates that the long link to be entered is not an already entered long link. Since it is a long link that has not been entered into the short link system, there will be no situation where the same long link corresponds to two different short links.
[0053] In the above situation, the short link generation request is directly responded to to generate a short link corresponding to the long link to be entered. The obtained short link can be directly stored in the short link system along with the long link to be entered.
[0054] Step S103: Store the long links to be entered and their corresponding short links in the first data table.
[0055] In this embodiment, the first data table is used to store the mapping relationship between the long link to be entered and the corresponding short link. That is, the long link to be entered is used as the primary key, and the long link to be entered and the corresponding short link are stored as values in the first data table.
[0056] For example, if the long link to be entered is found to be a primary key contained in the first data table, feedback information indicating request failure is returned to the requester. The feedback information includes the short link corresponding to the long link to be entered. In this embodiment, if the long link to be entered is found to be a primary key contained in the first data table, it indicates that the short link system has generated and stored the short link corresponding to the long link to be entered. To avoid generating multiple different short links for the same long link, this embodiment returns feedback information indicating request failure to the requester and ends the short link generation process.
[0057] See Figure 3 , Figure 3 This is a flowchart illustrating a method for generating short links according to an exemplary embodiment of this application, such as... Figure 3 As shown, the method for generating short links provided in this embodiment includes steps S901 to S907, which are described in detail below:
[0058] S901: Begin.
[0059] In this embodiment, after obtaining the short link to be entered, the process of generating the short link corresponding to the long link to be entered is initiated.
[0060] S902: Calculate the MD5 value corresponding to the long link to be entered.
[0061] S903: Query the first data table.
[0062] The first data table includes the MD5 values of multiple entered long links and the short links corresponding to each entered long link. The MD5 values of the entered long links serve as the primary key, and the short links corresponding to the entered long links are stored as key-value pairs in the first data table.
[0063] S904: Determine if the first data table contains the MD5 value corresponding to the long link to be entered. If yes, proceed to step S907; otherwise, proceed to step S905.
[0064] S905: Short links corresponding to long links to be entered.
[0065] S906: Use the MD5 value of the long link to be entered as the primary key, and the short link to be entered as the key value to store in the first data table.
[0066] S907: End the short link generation process.
[0067] The inventors of this application discovered that in the early stages, the mapping relationship between short links and long links was stored in memory, for example, using a fixed-length hashtable to store the mapping relationship between short links and long links. Because this method does not have persistent storage, data recovery can only be done by slicing and binlog pipeline in the event of machine failure. Scaling up and recovery from crashes are relatively complicated, and the operation and maintenance costs and machine costs are relatively high.
[0068] For example, CMEM (Cloud Memory) can be used to store the mapping between short and long links. CMEM is a high-performance, memory-based persistent storage service provided by Tencent, suitable for scenarios with small data volumes, high access volumes, and key-value storage. CMEM is based on a hashmap that stores key-value pairs, using memory for data storage and ensuring data persistence. Analysis revealed that while this approach solves data security and operational complexity issues, its machine costs are higher than previous storage methods because CMEM has its own data, resulting in lower overall memory utilization and faster data expansion, leading to increasing machine consumption.
[0069] Therefore, this embodiment uses a cache + SSD file storage method to store the mapping relationship between long links and short links. See also... Figure 4 , Figure 4 This is a schematic diagram illustrating the structure of a first data table in an exemplary embodiment of this application, as shown below. Figure 4 As shown, the first data table storage consists of a cache and SSD files. All write processes only write to the cache, and each record is timestamped. The write processes do not interact directly with the SSD, so there is no issue of random SSD writes, and the time consumption is very small.
[0070] The defragmentation tool is used to detect the cache capacity. When the cache capacity reaches a certain set value, defragmentation is started, merging the data in the cache and SSD. After the merger is completed, data in the cache before the defragmentation timestamp is evicted. Defragmentation is usually done once a week. This method can solve the write count limit of SSD files.
[0071] When the read process arrives, it first checks the data in the cache. If the data is not found, it will then check the SSD file. The optimized SSD file only needs to be read once, and the overall query time is very short, averaging within 1 to 2 ms.
[0072] The number of write processes per machine is determined by the number of SSD files. One write process will be started for each SSD file. Since the read process involves input and output operations, multiple corresponding read processes will generally be started for each SSD file.
[0073] After the write process writes the data to the cache, it also forwards a copy to the synchronization process. The synchronization process then synchronizes the data to other machines using the synchronization protocol, based on the configured backup machine information.
[0074] The interface machine is mainly used for routing. It calculates the unit to which the request belongs based on the primary key of the request, and then routes the request to the machine process where the unit is located. The primary key of the request is, for example, a long-lived link.
[0075] For example, see Figure 5 , Figure 5 This is a schematic diagram illustrating the structure of an SSD file in a first data table according to an exemplary embodiment of this application. The data in the first data table is divided into 4096 units, each unit corresponding to a file, and the file format is as follows: Figure 5 As shown, the file structure is divided into an index area and a data area. The index area is further divided into a first-level index area and a second-level index area. The data area and the second-level index area are logically composed of 8k blocks, while the first-level index area is composed of a 64k block.
[0076] In this embodiment, the 16-bit long link is converted into two 64-bit integers, sorted in ascending order. Each block can hold 340 records, and each record includes the long link and its corresponding short link, with a size of 24 bytes. The secondary index area is an index built on the data area. The primary key of the last record in each block is used to build the secondary index. Similarly, the primary index area is built from the primary key of the last record in each block of the secondary index.
[0077] The search process begins by performing a binary search on the primary index area to find the corresponding secondary index area. Then, a binary search is performed on the secondary index area to find the corresponding data block. Finally, a binary search is performed on the data block to locate the record being searched.
[0078] Because the primary and secondary index areas are very small, in order to reduce the number of input / output operations, the index is loaded into memory after each file is organized. Therefore, a search process actually only requires one input / output operation.
[0079] The method for generating short links provided in this embodiment stores the mapping relationship between long links and corresponding short links in a first data table, and uses the long link as the primary key in the data table. Based on the primary key, it can quickly determine whether the first data table stores a short link corresponding to the long link to be entered. Thus, before the short link is generated, the conflict situation of the same long link corresponding to two or more different short links can be avoided, thereby avoiding access errors when visitors access short links.
[0080] For example, see Figure 6 , Figure 6 yes Figure 2 Step S103 in the illustrated embodiment is shown in a flowchart of an exemplary embodiment, as follows: Figure 6 As shown, step S103 includes steps S201-S202, which are described in detail below:
[0081] Step S201: Obtain the MD5 value of the long link to be entered.
[0082] In this embodiment, the MD5 value of the long link to be entered is obtained based on the MD5 message-digest algorithm. The MD5 message-digest algorithm is a widely used cryptographic hash function that can produce a 128-bit (16-byte) hash value. Compared with other message-digest algorithms, the MD5 message-digest algorithm has better security and the obtained MD5 value is shorter than the long link to be entered.
[0083] Step S202: Store the MD5 value in the first data table.
[0084] In this embodiment, the MD5 value corresponding to the long link to be entered is stored as the primary key in the first data table. After receiving the short link generation request, the MD5 value corresponding to the long link to be entered is obtained, and it is queried whether the MD5 value corresponding to the long link to be entered is a primary key contained in the first data table. If the MD5 value corresponding to the long link to be entered is not a primary key contained in the first data table, the short link corresponding to the long link to be entered is generated in response to the short link generation request.
[0085] In this embodiment, the MD5 value corresponding to the long link is used to replace the long link in the first data table. Since the length of the MD5 value corresponding to the long link is much smaller than the long link, the storage space of the first data table can be further saved. Moreover, storing the MD5 value of the encrypted long link in the first data table can improve the security of data storage and avoid the leakage of long links.
[0086] For example, see Figure 7 , Figure 7 yes Figure 2Step S102 in the illustrated embodiment is shown in a flowchart of an exemplary embodiment, as follows: Figure 7 As shown, step S102 includes steps S301-S302, which are described in detail below:
[0087] Step S301: Perform hash calculation on the long link to be entered to obtain the hash value corresponding to the long link to be entered.
[0088] Hash computation, also known as hash calculation, transforms an input of arbitrary length (also called a pre-image) into a fixed-length output using a hash algorithm. This output is the hash value. This transformation is a compression mapping, meaning the space of hash values is usually much smaller than the space of inputs. Different inputs may hash to the same output, so it's impossible to determine a unique input value from the hash value. Simply put, it's a function that compresses a message of arbitrary length into a message digest of a fixed length.
[0089] For example, the MurmurHash algorithm is used to perform hash calculations on the long links to be entered, thereby obtaining the hash value corresponding to the long links to be entered.
[0090] The MurmurHash algorithm is a non-cryptographic hash function that processes data faster than other popular hash functions. In addition, for primary keys with strong regularity, the MurmurHash algorithm exhibits better random distribution characteristics.
[0091] The MurmurHash algorithm typically outputs hash values of two lengths: 32 bits and 128 bits. For example, to ensure the generated short links are as short as possible, this embodiment chooses to output a 32-bit hash value. For instance, performing a MurmurHash calculation on a long link to be entered outputs a 32-bit hash value: 3002604296.
[0092] Step S302: Convert the hash value into hexadecimal characters, and use the characters as the short links corresponding to the long links to be entered.
[0093] In this embodiment, the hash value corresponding to the long link to be entered obtained in step S301 is in decimal form. Converting the hash value in decimal form into hexadecimal characters can significantly shorten the length of the hash value to meet the requirements of short links and further improve the user experience.
[0094] In one exemplary embodiment, see Figure 8 , Figure 8 yes Figure 2 Step S102 in the illustrated embodiment is shown in a flowchart of an exemplary embodiment, as follows: Figure 8As shown, step S102 includes steps S401-S407, which are described in detail below:
[0095] Step S401: Generate a seed.
[0096] In this embodiment, the generated seed value is used as the parameter value of the MurmurHash algorithm. For example, the seed value of the MurmurHash algorithm is randomly generated. It should be noted that this embodiment can also generate the seed in other ways, which are not specifically limited here.
[0097] Step S402: Based on the long link to be entered and the seed, use the MurmurHash algorithm to obtain the hash value corresponding to the long link to be entered.
[0098] In this embodiment, the seed is incorporated into the MurmurHash algorithm. The long link to be entered is input into the MurmurHash algorithm model with the seed parameter, and the hash value corresponding to the long link to be entered can be output.
[0099] For example, if the long link to be entered is as follows:
[0100] https: / / test.ves.qq.com / match_detail_signup / index.html?tournamentId=1008
[0101] Based on the MurmurHash algorithm model with seed parameters, the hash value corresponding to the long link to be entered can be output.
[0102] If the long link to be entered is as follows:
[0103] If https: / / test.ves.qq.com / match_detail_signup / index.html?tournamentId=1008, the resulting hash value is 2340220928.
[0104] Step S403: Convert the decimal hash value to hexadecimal characters to obtain the short link corresponding to the long link to be entered.
[0105] For example, converting the hash value 2340220928 into hexadecimal yields the short link 8b7cf000 corresponding to the long link to be entered. Therefore, the short link finally generated in this embodiment is c.ves.qq.com / 8b7cf000.
[0106] Step S404: Confirm whether the generated short links have any conflicts.
[0107] In this embodiment, the generated short link is matched against a first data table. If a short link identical to the generated short link is found in the first data table, it is determined whether the generated short link conflicts. For example, if the generated short link is c.ves.qq.com / 8b7cf000, then if the first data table includes the short link c.ves.qq.com / 8b7cf000, a conflict is determined.
[0108] Step S405: If there is no conflict, store the mapping relationship between the long link to be entered and the corresponding short link in the first data table.
[0109] Step S406: If there is a conflict, add "vesports" to the end of the long link to be entered to generate a new long link to be entered.
[0110] Step S407: Generate corresponding short links for the new long links to be entered.
[0111] The inventors of this application have discovered that although existing technologies can generate short links corresponding to original long links, the method of automatically generating short links using hash algorithms is limited by the hash algorithm's maximum 16-bit base. This may result in the generation of the same short link for different long links, causing short link conflicts, which may also cause access errors when visitors access short links.
[0112] For example, see Figure 9 , Figure 9 yes Figure 2 Step S103 in the illustrated embodiment is shown in a flowchart of an exemplary embodiment, as follows: Figure 9 As shown, step S103 includes steps S501-S502, which are described in detail below:
[0113] Step S501: Query whether the first data table includes a target short link that is the same as the short link corresponding to the long link to be entered.
[0114] In this embodiment, after generating the short link corresponding to the long link to be entered, the first data table is queried to see if it contains the same target short link as the short link corresponding to the long link to be entered. If it exists, it means that the long link to be entered and the long link corresponding to the target short link in the first data table have generated the same short link, resulting in a short link generation conflict. If the short link corresponding to the long link to be entered and the long link to be entered are still written into the first data table at this time, it will definitely cause an access error when the visitor accesses the short link. Specifically, when the visitor accesses the short link corresponding to the long link to be entered (or the target short link), the visitor is redirected to the long link to be entered or the target long link, and the long link to be entered and the target long link are different network addresses.
[0115] Step S502: If it exists, add a preset string to the end of the long link to be entered to obtain a new long link to be entered, and generate a corresponding short link for the new long link to be entered.
[0116] In this embodiment, if the first data table is queried to see if it includes a target short link that is the same as the short link corresponding to the long link to be entered, so as to add a preset string after the long link to be entered, steps S101-S103 are re-executed to generate a corresponding short link for the new long link to be entered.
[0117] In this embodiment, when querying whether the first data table includes a target short link that is the same as the short link corresponding to the long link to be entered, the long link to be entered is changed, thereby triggering a short link generation request again to generate a new short link, thus avoiding short link generation conflicts.
[0118] For example, if the query checks whether the first data table includes a target short link that is identical to the short link corresponding to the long link to be entered, "vesports" is appended to the long link to be entered to generate a new long link to be entered. For example, the long link to be entered is as follows:
[0119] https: / / test.ves.qq.com / match_detail_signup / index.html?tournamentId=1008
[0120] The generated new long links to be entered are as follows:
[0121] https: / / test.ves.qq.com / match_detail_signup / index.html?tournamentId=1008vesports.
[0122] Through long-term research, the inventors of this application have discovered that currently, short link systems store the mapping relationship between long links and corresponding short links in a data table. Both short link generation and short link conversion are based on this data table. Since the current short link conversion business has extremely high concurrency, it may cause excessively long delays in short link generation requests, resulting in low efficiency in short link generation.
[0123] To address the aforementioned issues, this embodiment stores the long links to be entered and their corresponding short links in a second data table using a key-value pair storage method, with the short links corresponding to the long links to be entered serving as the primary key.
[0124] In this embodiment, a second data table is constructed to store the mapping relationship between the long links to be entered and the corresponding short links. The long links to be entered serve as the primary key in the second data table. The second data table can be used to handle various business processes, such as short link conversion, etc., without specific limitations.
[0125] In this embodiment, a second data table is constructed to store the mapping relationship between short links and corresponding long links. The end link is used as the primary key in the second data table, and this second data table is used to process short link conversion business. That is, the first data table is used to process short link generation business, and the second data table is constructed to process short link conversion business. This can solve the problem that the high concurrency of the current short link conversion business may cause the short link generation request to be too delayed and the short link generation efficiency to be low.
[0126] Similarly, this embodiment uses a cache + SSD file storage method to store the mapping relationship between short links and long links. The data stored in the second data table is the mapping between short links and long links. In this embodiment, the second data table reuses the program of the first data table, with only some code modifications.
[0127] For example, see Figure 10 , Figure 10 This is a schematic diagram illustrating the structure of the SSD file in the second data table according to an exemplary embodiment of this application, such as... Figure 10 As shown, the second data table consists of three parts: file header, index, and data. The file header records the attribute information of the unit, the index is an array with 15 million elements, the array index is the offset of the short link within the unit, and the array value is the offset of the content of the short link in the file.
[0128] For a single query process, the index position is first calculated, the index value is read, and then the value corresponding to the primary key is read according to the offset. Because the index is large, it is not loaded into memory. A single query requires two file inputs and outputs. SSD file reading is very fast, and the query time is basically within 1 to 2 ms.
[0129] For example, the MD5 value is stored in a second data table. In this embodiment, the MD5 value corresponding to the long link is used instead of the long link itself and stored in the second data table. Since the length of the MD5 value corresponding to the long link is much shorter than the long link, the storage space of the second data table can be further saved. Moreover, storing the MD5 value of the encrypted long link in the second data table can improve the security of data storage and prevent the long link from being leaked.
[0130] See Figure 11 , Figure 11 This is a schematic diagram illustrating a method for generating short links according to an exemplary embodiment of this application, as shown below. Figure 11As shown, after calculating the MD5 value corresponding to the long link to be entered and generating the short link corresponding to the long link to be entered, the MD5 value is used as the primary key and the short link corresponding to the long link to be entered is used as the key-value pair in the first data table. The short link corresponding to the long link to be entered is used as the primary key and the MD5 value corresponding to the long link to be entered is used as the key-value pair in the second data table. The second data table is used to handle the short link conversion business. That is, the first data table is used to handle the short link generation business and the second data table is used to handle the short link conversion business. This can solve the problem of excessively long latency of short link generation requests and low efficiency of short link generation caused by the high concurrency of the current short link conversion business.
[0131] See Figure 12 , Figure 12 Is Figure 2 The flowchart of the short link generation method proposed in the illustrated embodiment is as follows: Figure 12 As shown, after step S103, the method for generating short links provided in this embodiment further includes steps S601-S602, which are described in detail below:
[0132] Step S601: Receive a short link conversion request, which includes the short link to be converted.
[0133] In this embodiment, the short link conversion request is sent by the client device, which can be a smartphone, tablet, PC (Personal Computer), smart voice interaction device, smart home appliance, vehicle terminal, or any other electronic device capable of running applications. No restrictions are imposed here.
[0134] For example, a push notification containing a short link to be converted is sent to the client device. When the user clicks the short link, a short link conversion request is triggered. The push notification may include multiple variables, such as username, date, etc., without specific limitations. When responding to the short link conversion request, i.e., when obtaining the long link corresponding to the short link to be converted, the value of each variable is passed into the long link, thus redirecting the user to the page corresponding to the long link.
[0135] For example, a push notification containing a shortened link to be converted is sent to an application included in the client device. For instance, if the client device includes a game application, a push notification is sent to the user after the user finishes the game to allow them to view the user's ranking. The push notification title is "Advanced!" and the content is "Congratulations on advancing! Click {url} to view {name}'s ranking." Here, url is the shortened link to be converted, and name is the username. Clicking the url in the shortened link information will trigger a shortened link conversion request.
[0136] For example, a push notification is sent to the client device in the form of an SMS message. For instance, the title of the push notification is "Your service has been suspended," and the content is "Dear customer, to ensure your normal communication, please pay your bill in time before {date} to avoid the inconvenience caused by service suspension due to arrears. Click the link {url} to easily pay your bill." Here, date is the deadline for payment, and url is the short link to be converted.
[0137] For example, see Figure 13 , Figure 13 Is Figure 2 The flowchart of the short link generation method proposed in the illustrated embodiment is as follows: Figure 13 As shown, after step S101, the method for generating short links provided in this embodiment further includes steps S701-S702, which are described in detail below:
[0138] Step S701: Increment the cumulative number of short link conversion requests within a preset time period based on the received short link conversion requests.
[0139] In the actual operation of short link conversion, if the cumulative number of conversion requests for a short link to be converted is too high within a short period of time, it indicates that the short link to be converted may be a currently trending link, meaning that the information contained in the short link to be converted may be currently popular information. Furthermore, if the cumulative number of conversion requests for a short link to be converted is too high within a short period of time, it may also indicate that the short link to be converted is being maliciously clicked. Therefore, in this embodiment, counting the cumulative number of conversion requests for a short link to be converted within a preset time period is of significant value.
[0140] Step S702: If the cumulative number of request conversions exceeds the preset threshold, the short link to be converted is treated as an abnormal request short link, and abnormal request information is sent to the management platform.
[0141] In this embodiment, the abnormal request information includes abnormal request short links. It is understood that the preset time period and preset threshold can be flexibly set according to the actual application scenario, and are not specifically limited here.
[0142] For example, after receiving abnormal request information, the management platform can quickly verify the abnormal request short link. If it is found that the abnormal request short link is being maliciously clicked, the IP address of the short link to be converted can be used to query the identity information of the user who maliciously clicked it. If it is found that the abnormal request short link is a currently popular link, a notification message can be sent to the server to increase the push of the link to be converted, thereby improving the user experience.
[0143] For example, the top N short links to be converted that have the most cumulative conversion requests within a preset time period are counted and sent to the management platform. When the management platform detects malicious clicking on short links, it first verifies these N short links to be converted, thereby speeding up the malicious detection process.
[0144] Step S602: If the short link to be converted is found to be a primary key contained in the second data table, then obtain the long link corresponding to the short link to be converted based on the primary key, and redirect to the long link corresponding to the short link to be converted.
[0145] In this embodiment, if the short link to be converted is found to be a primary key contained in the second data table, it means that the short link to be converted is included in the second data table, and the second data table also includes a long link corresponding to the short link to be converted. At this time, the long link corresponding to the short link to be converted is obtained based on the primary key, and the user is redirected to the long link corresponding to the short link to be converted.
[0146] In this embodiment, redirecting to the long link corresponding to the short link to be converted means sending the long link corresponding to the short link to the client so that the client jumps to the page corresponding to the long link.
[0147] In this embodiment, if the value corresponding to the primary key of the second data table is the MD5 value of the long link to be entered, after receiving the short link conversion request, if it is found that the short link to be converted is the primary key contained in the second data table, then the MD5 value corresponding to the short link to be converted is obtained from the second data table based on the primary key, and the MD5 value is converted into a long link and redirected to the long link.
[0148] In a specific application scenario, a short link conversion request is received from a game client. This request includes a game-related short link to be converted. If the short link to be converted is a primary key contained in a second data table, the corresponding long link is retrieved based on the primary key, and the user is redirected to that long link. The game-related short link is used to implement game-related functions during the player's login process. For example, after a player finishes a game, a push notification is sent to the game application interface to display the player's ranking. The push notification title is "Advanced!" and the content is "Congratulations on advancing! Click {url} to view {name}'s ranking." Here, url is the short link to be converted, and name is the username. After the player clicks the url in the short link information, a short link conversion request is sent to the server. The server queries the second data table based on the short link conversion request. If the short link to be converted is a primary key contained in the second data table, the corresponding long link is retrieved based on the primary key, and the user is redirected to that long link. This method facilitates players viewing their rankings after a match, improving the user experience.
[0149] For example, after obtaining the long link corresponding to the short link to be converted based on the primary key, the long link is judged for security. If it is judged to be a normal link, it is redirected to the page corresponding to the long link via a 302 redirect. If it is judged to be a dangerous link, it is redirected to the reporting page of the security center to remind the user that the link is risky.
[0150] For example, to address the issue of mismatched domains between the short link to be converted and its corresponding long link, leading to multiple redirects and low conversion efficiency, consider a short link (http: / / t.cn / abcdefg) shared to system A but belonging to system B. After being entered into system A, it generates http: / / url.cn / 123456. When a user clicks this short link, the server first redirects to the short link server of system B to obtain conversion authorization before finally redirecting to the target page, requiring multiple redirects. To solve this problem, during entry or querying, the domain of the long link is matched with the short link to be converted. The target long link matching the domain of the short link to be converted is saved to a second data table. Subsequently, when converting the short link to be converted, the target long link is directly returned. In this way, the conversion efficiency of the short link to be converted can be improved.
[0151] See Figure 14 , Figure 14 Is Figure 2 The flowchart of the short link generation method proposed in the illustrated embodiment is as follows: Figure 14As shown, after step S103, the method for generating short links provided in this embodiment further includes steps S1100-S1500, which are described in detail below:
[0152] Step S1100: Receive short link conversion request.
[0153] Step S1200: If the short link to be converted is found to be a primary key included in the second data table, then obtain the long link corresponding to the short link to be converted based on the primary key.
[0154] Step S1300: Perform security checks on long links.
[0155] Step S1400: If the long link is detected to be in a normal state, redirect to the long link.
[0156] Step S1500: If a long link is detected as being in an abnormal state, the user is prompted that the long link poses a risk and the short link conversion process is exited.
[0157] This embodiment performs short link conversion based on the second data table and short link generation based on the first data table. This avoids the problem of excessively long delays in short link conversion requests and low efficiency caused by the short link conversion and short link generation services being performed on the same data table.
[0158] participate Figure 15 , Figure 15 This is a block diagram illustrating a short link generation apparatus according to an exemplary embodiment of this application, such as... Figure 15 As shown, the short link generation device 800 includes a first receiving module 801, a short link generation module 802, and a first storage module 803.
[0159] The first receiving module 801 is used to receive a short link generation request, which includes a long link to be entered. The short link generation module 802 is used to generate a short link corresponding to the long link to be entered if the long link to be entered is not a primary key contained in the first data table. The first data table is used to store the entered long links and their corresponding short links in a key-value pair storage method, and uses the entered long links as primary keys. The first storage module 803 is used to store the long link to be entered and its corresponding short link in the first data table.
[0160] In another exemplary embodiment, the short link generation device 800 provided in this embodiment further includes a second storage module, wherein the second storage module is used to store the long link to be entered and the short link corresponding to the long link to be entered in a second data table in a key-value pair storage method, and uses the short link corresponding to the long link to be entered as the primary key.
[0161] In another exemplary embodiment, the short link generation apparatus 800 provided in this embodiment further includes a second receiving module and a redirection module. The receiving module is used to receive a short link conversion request, which includes a short link to be converted. The redirection module is used to obtain the long link corresponding to the short link to be converted based on the primary key if the short link to be converted is found to be a primary key contained in the second data table, and redirect to the long link corresponding to the short link to be converted.
[0162] In another exemplary embodiment, the second storage module includes an acquisition unit and a storage unit, wherein the acquisition unit is used to acquire the MD5 value of the long link to be entered; and the storage unit is used to store the MD5 value in a second data table.
[0163] In another exemplary embodiment, the short link generation module 802 includes a calculation unit and a conversion unit. The calculation unit is used to perform hash calculation on the long link to be entered to obtain the hash value corresponding to the long link to be entered. The conversion unit is used to convert the hash value into hexadecimal characters and use the characters as the short link corresponding to the long link to be entered.
[0164] In another exemplary embodiment, the short link generation apparatus 800 provided in this embodiment further includes an accumulation module and a sending module. The accumulation module is used to increment the cumulative number of request conversions of the short link to be converted within a preset time period based on the received short link conversion requests. The sending module is used to send abnormal request information to the management platform if the obtained cumulative number of request conversions exceeds a preset threshold, treating the short link to be converted as an abnormal request short link. The abnormal request information includes the abnormal request short link.
[0165] It should be noted that the apparatus provided in the above embodiments and the method provided in the above embodiments belong to the same concept, and the specific way in which each module and unit performs operations has been described in detail in the method embodiments, and will not be repeated here.
[0166] In another exemplary embodiment, this application provides an electronic device including a processor and a memory, wherein the memory stores computer-readable instructions that, when executed by the processor, implement the aforementioned account recharge prompt method. In this embodiment, the electronic device includes, but is not limited to, mobile phones, computers, smart voice interaction devices, smart home appliances, and in-vehicle terminals.
[0167] Figure 16 A schematic diagram of the structure of a computer system suitable for implementing the electronic device of the present application is shown.
[0168] It should be noted that, Figure 16 The computer system 1000 of the electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.
[0169] like Figure 16 As shown, the computer system 1000 includes a Central Processing Unit (CPU) 1001, which can perform various appropriate actions and processes based on programs stored in Read-Only Memory (ROM) 1002 or programs loaded from storage portion 1008 into Random Access Memory (RAM) 1003, such as executing the information recommendation method described in the above embodiments. Various programs and data required for system operation are also stored in RAM 1003. The CPU 1001, ROM 1002, and RAM 1003 are interconnected via bus 1004. An Input / Output (I / O) interface 1005 is also connected to bus 1004.
[0170] The following components are connected to I / O interface 1005: an input section 1006 including a keyboard, mouse, etc.; an output section 1007 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 1008 including a hard disk, etc.; and a communication section 1009 including a network interface card such as a LAN (Local Area Network) card, modem, etc. The communication section 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to I / O interface 1005 as needed. Removable media 1011, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., are installed on drive 1010 as needed so that computer programs read from them can be installed into storage section 1008 as needed.
[0171] Specifically, according to embodiments of this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program including a computer program for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 1009, and / or installed from removable medium 1011. When the computer program is executed by central processing unit (CPU) 1001, it performs various functions defined in the system of this application.
[0172] It should be noted that the computer-readable medium shown in the embodiments of this application can be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable compact disc read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this application, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this application, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying a computer-readable computer program. The transmitted data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The computer program contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to wireless, wired, etc., or any suitable combination thereof.
[0173] It is understood that in the specific embodiments of this application, data related to user information, etc., are involved. When the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0174] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. Each block in a flowchart or block diagram may represent a module, segment, or portion of code, which contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0175] The units described in the embodiments of this application can be implemented in software or hardware, and the described units can also be located in a processor. The names of these units do not necessarily limit the specific unit itself.
[0176] Another aspect of this application provides a computer-readable storage medium storing computer-readable instructions that, when executed by a processor, implement a method for generating short links as described in any of the preceding embodiments.
[0177] Another aspect of this application provides a computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the short link generation method provided in the various embodiments described above.
[0178] It should be noted that the computer-readable medium shown in the embodiments of this application can be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable compact disc read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this application, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this application, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying a computer-readable computer program. The transmitted data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The computer program contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to wireless, wired, etc., or any suitable combination thereof.
[0179] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. Each block in a flowchart or block diagram may represent a module, segment, or portion of code, which contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0180] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all content and operations / steps, nor do they necessarily have to be performed in the described order. For example, some operations / steps can be broken down, while others can be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.
[0181] The units described in the embodiments of this application can be implemented in software or hardware, and the described units can also be located in a processor. The names of these units do not necessarily limit the specific unit itself.
[0182] The above description is merely a preferred exemplary embodiment of this application and is not intended to limit the implementation of this application. Those skilled in the art can easily make corresponding modifications or alterations based on the main concept and spirit of this application. Therefore, the scope of protection of this application should be determined by the scope of protection claimed in the claims.
Claims
1. A method for generating short links, characterized in that, include: Receive a short link generation request, wherein the short link generation request includes a long link to be entered; If the long link to be entered is not a primary key contained in the first data table, then the short link corresponding to the long link to be entered is generated in response to the short link generation request. The first data table is used to store the entered long links and corresponding short links in a key-value pair storage method, and the entered long links are used as primary keys. The domain name of the long link to be entered is matched with the domain name of the short link corresponding to the long link to be entered, so as to obtain the target long link that matches the domain name of the short link corresponding to the long link to be entered. The target long link and the short link corresponding to the long link to be entered are stored in the second data table using a key-value pair storage method, and the short link corresponding to the long link to be entered is used as the primary key. The long link to be entered is used as the primary key, and the short link corresponding to the long link to be entered is used as the value, and stored in the first data table; If the long link to be entered is found to be a primary key contained in the first data table, then feedback information indicating that the request failed is returned to the requester, and the feedback information includes the short link corresponding to the long link to be entered. Receive a short link conversion request, the short link conversion request including the short link to be converted; Based on the received short link conversion request, increment the cumulative number of conversion requests for the short link to be converted within the preset time period by one; If the cumulative number of request conversions exceeds a preset threshold, the short link to be converted will be treated as an abnormal request short link, and abnormal request information will be sent to the management platform. The abnormal request information includes the abnormal request short link. If the short link to be converted is found to be a primary key contained in the second data table, then the target long link corresponding to the short link to be converted is obtained based on the primary key, and redirection is performed to the target long link corresponding to the short link to be converted.
2. The method according to claim 1, characterized in that, The step of storing the target long link and the short link corresponding to the long link to be entered in the second data table using a key-value pair storage method includes: Obtain the MD5 value of the target long link; The MD5 value is stored in the second data table.
3. The method according to claim 1, characterized in that, The process of generating the short link corresponding to the long link to be entered in response to the short link generation request includes: Perform a hash calculation on the long link to be entered to obtain the hash value corresponding to the long link to be entered; The hash value is converted into hexadecimal characters, and these characters are used as the short links corresponding to the long links to be entered.
4. A device for generating short links, characterized in that, include: The first receiving module is used to receive a short link generation request, wherein the short link generation request includes a long link to be entered. The short link generation module is used to generate a short link corresponding to the long link to be entered in response to the short link generation request if the long link to be entered is not a primary key contained in the first data table. The first data table is used to store the entered long links and their corresponding short links in a key-value pair storage method, and the entered long links are used as primary keys. If the long link to be entered is found to be a primary key contained in the first data table, feedback information indicating that the request failed is returned to the requester. The feedback information includes the short link corresponding to the long link to be entered. The first storage module is used to store the long link to be entered as the primary key and the short link corresponding to the long link to be entered as the value in the first data table. The second storage module is used to match the domain name of the long link to be entered with the domain name of the short link corresponding to the long link to be entered, and obtain the target long link that matches the domain name of the short link corresponding to the long link to be entered; the target long link and the short link corresponding to the long link to be entered are stored in the second data table through key-value pair storage method, and the short link corresponding to the long link to be entered is used as the primary key. The second receiving module is used to receive a short link conversion request, wherein the short link conversion request includes a short link to be converted. The cumulative module is used to increment the cumulative number of short link conversion requests received within a preset time period by one. The sending module is used to send abnormal request information to the management platform if the cumulative number of request conversions exceeds a preset threshold. The abnormal request information includes the abnormal request short link. The redirection module is used to, if the short link to be converted is found to be a primary key contained in the second data table, obtain the target long link corresponding to the short link to be converted based on the primary key, and redirect to the target long link corresponding to the short link to be converted.
5. An electronic device, characterized in that, include: Memory, which stores computer-readable instructions; A processor reads computer-readable instructions stored in memory to perform the method described in any one of claims 1-3.
6. A computer-readable storage medium, characterized in that, It stores computer-readable instructions that, when executed by the computer's processor, cause the computer to perform the method described in any one of claims 1-3.
7. A computer program product, characterized in that, Includes computer instructions, which are stored in a computer-readable storage medium; The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions to cause the computer device to perform the method of any one of claims 1-3.
Citation Information
Patent Citations
Information pushing method and device, computer equipment and storage medium
CN110662184A
Short link generation method, server, storage medium and computer equipment
CN110851748A
Short link generation method and device and server
CN111026985A