Short link generation method and device, equipment and storage medium

By introducing continuous and random factors during the short link generation process, combined with deduplication, the hash collision problem is solved, the security and effectiveness of short links are improved, and the uniqueness of short links in high-concurrency environments is ensured.

CN117473176BActive Publication Date: 2026-07-03SHENZHEN MONTNETS TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SHENZHEN MONTNETS TECH CO LTD
Filing Date
2023-10-26
Publication Date
2026-07-03

Smart Images

  • Figure CN117473176B_ABST
    Figure CN117473176B_ABST
Patent Text Reader

Abstract

This application discloses a method, apparatus, device, and storage medium for generating short links, belonging to the field of computer technology. The method includes: receiving a service request from a user terminal, the service request carrying long link information, the service request requesting the generation of N short links, where N is an integer greater than 1; generating N short codes based on a continuous factor, a random factor, and the long link information, each short code being a string, the continuous factor including a first string sequence comprising N regular first strings, and the random factor including N random second strings; performing deduplication processing on the N short codes, and generating N target short links based on the deduplication result, thereby reducing the probability of hash collisions in scenarios with a large number of short link requests and improving the effectiveness of the short links.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, device and storage medium for generating short links. Background Technology

[0002] With the rapid development of information technology, URLs contain more and more information, and their lengths are also increasing. URLs that are excessively long (e.g., exceeding a threshold) are generally called long links. Currently, there are limitations on the length of content sent in a single SMS message. For SMS messages containing long links, if the links are too long, they consume too many unnecessary characters and negatively impact the user experience. Therefore, it is necessary to convert long links into short links and maintain a mapping between short and long links in the background. When a short link is sent to the terminal and clicked, the terminal will redirect, causing the browser to jump to the page corresponding to the long link. A short link refers to a URL whose length is shorter than a long link (e.g., less than or equal to a threshold).

[0003] Current link shortening technologies use hash algorithms to perform hash operations on long links before converting them into short links, in order to ensure the randomness of the short link code. However, although hash algorithms have high randomness, they can still collide in scenarios with tens or hundreds of millions of requests. This means that different long links may generate the same short link after hashing, reducing the effectiveness of the short links. Summary of the Invention

[0004] This application provides a method, apparatus, device, and storage medium for generating short links, thereby improving the effectiveness of short links. The technical solution is as follows:

[0005] In a first aspect, a method for generating short links is provided. The method includes: receiving a service request from a user, the service request carrying long link information, the service request being used to request the generation of N short links, where N is an integer greater than 1; generating N short codes based on a continuous factor, a random factor, and the long link information, each short code being a string, the continuous factor including a first string sequence, the first string sequence including N first strings with a regularity, the random factor including N second strings with randomness; performing deduplication processing on the N short codes, and generating N target short links based on the deduplication processing result.

[0006] Secondly, a short link generation device is provided, the device comprising: a receiving module, configured to receive a service request from a user terminal, the service request carrying long link information, the service request requesting the generation of N short links, where N is an integer greater than 1; a generation module, configured to generate N short codes based on a continuous factor, a random factor, and the long link information, each short code being a string, the continuous factor including a first string sequence, the first string sequence including N first strings with a regularity, the random factor including N second strings with randomness; and a deduplication module, configured to perform deduplication processing on the N short codes, and generate N target short links based on the deduplication processing result.

[0007] Thirdly, a computer device is provided, the computer device including a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program implementing the method described in the first aspect when executed by the processor.

[0008] Fourthly, a computer-readable storage medium is provided, the computer-readable storage medium storing a computer program that, when executed by a processor, implements the method described in the first aspect.

[0009] Fifthly, a computer program product containing instructions is provided that, when run on a computer, causes the computer to perform the method described in the first aspect.

[0010] This application provides a method, apparatus, device, and storage medium for generating short links. According to the solution provided, a service request from a user terminal is received. The service request carries long link information and requests the generation of N short links, where N is an integer greater than 1. Based on a continuous factor, a random factor, and the long link information, N short codes are generated. Each short code is a string. The continuous factor includes a first string sequence containing N regular first strings, and the random factor includes N random second strings. By adding the continuous factor, the regularity and orderliness of the short codes are improved, reducing the occurrence of hash collisions. By adding the random factor, the randomness of the short codes is improved, thereby enhancing the security of short link generation. Deduplication is performed on the N short codes, and N target short links are generated based on the deduplication results. Through deduplication, duplicate short links (obtained by converting the short code's base) can be regenerated, improving the effectiveness of the short links. By adding continuous and random factors and performing deduplication operations, short links are generated in batches, increasing the dispersion of the generated results and reducing the probability of hash collisions in scenarios with large batches of short link requests, thus improving the effectiveness of the short links. Attached Figure Description

[0011] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0012] Figure 1 This is a flowchart of a short link generation method provided in an embodiment of this application;

[0013] Figure 2 This is a flowchart of another short link generation method provided in the embodiments of this application;

[0014] Figure 3 This is a flowchart of another short link generation method provided in the embodiments of this application;

[0015] Figure 4 This is a flowchart of yet another short link generation method provided in the embodiments of this application;

[0016] Figure 5 This is a schematic diagram of the structure of a short link generation device provided in an embodiment of this application;

[0017] Figure 6 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation

[0018] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.

[0019] It should be understood that "multiple" as mentioned in this application refers to two or more. In the description of this application, unless otherwise stated, " / " indicates "or," for example, A / B can mean A or B; "and / or" in this document is merely a description of the relationship between related objects, indicating that three relationships can exist, for example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Furthermore, to facilitate a clear description of the technical solutions of this application, the terms "first," "second," etc., are used to distinguish identical or similar items with essentially the same function and effect. Those skilled in the art will understand that the terms "first," "second," etc., do not limit the quantity or execution order, and that "first," "second," etc., do not necessarily imply differences.

[0020] Before providing a detailed explanation of the embodiments of this application, the application scenarios and related technologies of the embodiments of this application will be described first.

[0021] In related technologies, the length of a single SMS message is limited. When sending an SMS message containing a Uniform Resource Locator (URL), a long URL consumes too many unnecessary characters. Therefore, long URLs need to be converted into short URLs, i.e., short links or short addresses. Short link generation technologies can use either auto-incrementing sequence algorithms or hash algorithms. However, short links generated by auto-incrementing sequence algorithms are generally lexicographically ordered and regular, posing security risks. Hash algorithms offer higher randomness than auto-incrementing sequence algorithms, but in scenarios with tens or hundreds of millions of requests, hash algorithms still have a high probability of hash collisions, requiring significant resources to resolve this issue.

[0022] The application scenario of this application embodiment can be a scenario of generating short links in batches. For example, a merchant requests the generation of short links in batches through the short link generation service platform provided in this application, and then sends text messages with short links to many mobile phone users. Here, generating short links in batches can be based on one long link to generate multiple short links, reflecting personalization; or it can be based on multiple long links to generate multiple corresponding short links, with one long link corresponding to one short link.

[0023] This application provides a method for generating short links, such as... Figure 1 As shown, Figure 1 This is a flowchart of a short link generation method provided in an embodiment of this application. The short link generation method includes:

[0024] S101. Receive the user's business request. The business request carries long connection information and is used to request the generation of N short connections, where N is an integer greater than 1.

[0025] In this embodiment, the user terminal refers to the terminal or server used by a user (e.g., a merchant) who needs to generate short links in batches. The short link generation method can be executed by a short link service platform, which receives business requests from the user terminal.

[0026] The business request carries long link information, which includes at least the long link itself, and may also include other information such as a long link identifier (identity document, id) and a mini-program ID. For example, long link information can also be understood as business page information, which includes the long link, the long link identifier (identity document, id), and the mini-program ID. The long link information can include one or N long links. In a scenario with one long link, the user requests the batch generation of N personalized short links; in a scenario with N long links, the user requests the generation of each short link individually, meaning one short link corresponds to one long link.

[0027] The business request also carries the user-configured short link length, which represents the number of bits in the short link. The short link length is configured according to the number of short links to be generated, meaning the user can configure the number of bits in the short links according to their needs; the short link length can be 5-8 bits. A link can also be called a Uniform Resource Identifier (URI), a string used to identify the name of an internet resource. A short URI can consist of 66 characters: letters AZ, az, 0-9, '-' (minus sign), '_' (underscore), '.' (period), and '~' (tilde sign), i.e., a 66-bit hexadecimal string.

[0028] It should be noted that short URIs can also consist of 62 characters, namely the letters AZ, az, and 0-9, which are 62-bit base-62 strings. In practical applications, either 62-bit or 66-bit can be chosen. If other bases are required, new characters can be added or characters can be deleted. However, the added new characters must be legal characters allowed in the URL. Generally, base-62 or base-66 is used. This application does not impose specific restrictions on the characters that make up the short link.

[0029] For example, Table 1 below illustrates the range of 5-8 character strings represented in base 66.

[0030] Table 1

[0031] Decimal Number of digits quantity 66^5 1252332576 31-1 >1.2 billion 66^6 82653950016 37-1 >82.6 billion 66^7 5455160701056 43-1 >5 trillion 66^8 360040606269696 49-1 >360 trillion

[0032] The number of 5-digit hexadecimal short links (link length 5) in Table 1 above is greater than 1.2 billion (i.e., the corresponding decimal number is 1,252,332,576), and its binary number includes 31 bits to 1 bit; the number of 6-digit hexadecimal short links (link length 6) is greater than 82.6 billion (i.e., the corresponding decimal number is 82,653,950,016), and its binary number includes 37 bits to 1 bit; 7 The number of 7-bit hexadecimal short links is greater than 5 trillion (equivalent to 5455160701056 decimal numbers), with binary bits ranging from 43 to 1. The number of 8-bit hexadecimal short links (equivalent to 8 decimal numbers) is greater than 360 trillion (equivalent to 360040606269696 decimal numbers), with binary bits ranging from 49 to 1. The number of bits in a short link is proportional to the number of short links needed; if a large number of short links are required, a longer number of bits can be configured.

[0033] It should be noted that the short link generation method provided in this application supports generating URI addresses with lengths of 5, 6, 7, or 8 characters. The specific length can be appropriately configured by those skilled in the art according to actual circumstances (e.g., user requirements).

[0034] S102. Based on the continuous factor, random factor, and long link information, generate N short codes. Each short code is a string. The continuous factor includes a first string sequence, which includes N first strings with a regularity. The random factor includes N second strings with randomness.

[0035] In this embodiment, the continuous factor includes N first strings with a regularity. The first strings can be serial numbers; for example, the N first strings can be serial numbers from 1 to N, or from N to 1, or from N+1 to 2N, or N different timestamps. This embodiment does not limit the specific data of the continuous factor, as long as it has a regularity. The random factor includes N second strings with randomness. The second strings can be random numbers or random node numbers used to run business requests. This embodiment does not limit the specific data of the random factor, as long as it has randomness.

[0036] The long link information can include one or N long links. For a single long link, the long link is added to each of the first strings in the continuous factor and each of the second strings in the random factor to generate short codes. N short links correspond to one long link. For N long links, each long link is added to each of the first strings in the continuous factor and each of the second strings in the random factor, one-to-one, to generate short codes. One short link corresponds to one long link.

[0037] The aforementioned random and continuous factors can be collectively referred to as operational factors. If the operational factors only contain random factors, pseudo-randomness may occur. Therefore, to avoid pseudo-randomness, continuous factors need to be added. If the operational factors only contain continuous factors, insufficient randomness or regularity may occur. Therefore, to avoid insufficient randomness or regularity, random factors need to be added.

[0038] In this embodiment, the operation factor includes a continuous factor and a random factor. By adding a random factor, the generated short link sequence has higher randomness and lacks general regularity for general short link generation scenarios. For scenarios of batch generation of short links, adding continuous and random factors before mapping (e.g., hash operation) results in higher dispersion, reduces the probability of hash collisions, and improves the effectiveness of short links.

[0039] S103. Perform deduplication on the N short codes and generate N target short links based on the deduplication results.

[0040] In this embodiment, the short links (i.e., short URIs) generated by adding random and continuous factors have strong randomness and a very small probability of duplication with historical data. In the event of duplication, a new URI needs to be generated. Deduplication is performed based on N short codes. For duplicate short links, new short links are generated until N short links are unique, yielding the deduplication result. Then, multiple application programming interfaces (APIs) are called to insert the N unique short links into the database until all N short links are successfully inserted, resulting in N target short links. By regenerating duplicate short links (obtained by converting the short code's base), short links are generated in batches, improving their effectiveness.

[0041] The short link service platform receives short link generation requests (i.e., business requests) from users. These requests are for batch generation of short links, for example, requesting the generation of N short links. The short link service platform calls the API interface based on the short link generation request, executing the short link generation method provided in this application to generate short links in batches. For example, the original long link (corresponding to the long link information) is: https: / / blog.csdn.net / suifeng30451 / article / details / 38787613. The short link service platform generates the following short link: https: / / suo.nz / 378IQe, where "suo.nz" is the short domain name (the domain name of the short link server corresponding to the short link service platform), and "378IQe" is the specific short link, generated from the large segment blog.csdn.net / suifeng30451 / article / details / 38787613 in the long link. This short link generation method improves the randomness and discreteness of the generated short links by adding continuous and random factors, thereby enhancing the security and effectiveness of the short links.

[0042] According to the solution provided in this application, a business request is received from the user terminal. The business request carries long link information and requests the generation of N short links, where N is an integer greater than 1. Based on a continuous factor, a random factor, and the long link information, N short codes are generated. Each short code is a string. The continuous factor includes a first string sequence, which consists of N regular first strings. The random factor includes N random second strings. By adding the continuous factor, the regularity and orderliness of the short codes are improved, reducing the occurrence of hash collisions. By adding the random factor, the randomness of the short codes is improved, thereby enhancing the security of short link generation. Deduplication is performed on the N short codes, and N target short links are generated based on the deduplication results. Through deduplication, duplicate short links (obtained by converting the short code's base) can be regenerated, improving the effectiveness of the short links. By adding continuous and random factors and performing deduplication operations, short links are generated in batches, increasing the dispersion of the generated results and reducing the probability of hash collisions in scenarios with large batches of short link requests, thus improving the effectiveness of the short links.

[0043] In some embodiments, the first string sequence includes at least one of the following: a timestamp sequence, a first incrementing sequence, and a first decrementing sequence, wherein the timestamp sequence includes the generation timestamp of each short code to be generated; and the random factor includes at least one of the following: a random number and a node identifier corresponding to the node used to run the business request.

[0044] In this embodiment, the random factor is random, and the continuous factor is continuous, for example, continuously increasing or continuously decreasing. The random factor includes at least one of the following: a random number, a node identifier corresponding to the node used to run the business request, and at least one of the random number and the node identifier constitutes a second string; wherein, the random number can be generated in real time by a random system; the node identifier represents the number of the service program, and when processing a business request, different servers or different processing nodes (i.e., service programs, also known as running instances) can be used, and it is used to uniquely represent a service when multiple services are deployed. The continuous factor includes at least one of the following: timestamp, auto-incrementing sequence number, and auto-decrementing sequence number, wherein at least one of the timestamp, auto-incrementing sequence number, and auto-decrementing sequence number constitutes the first string; wherein the timestamp is the generation timestamp when generating each short code (including the initially generated short code and the short code regenerated during the deduplication process); the auto-incrementing sequence number increments by 1 each time, and can be from 1 to N, for example, 1, 2…N, or from 0 to N-1, for example, 0, 1…N-1, or from N+1 to 2N, for example, N+1, N+2…2N; the auto-decrementing sequence number decrements by 1 each time, and can be from N to 1, for example, N, N-1…1, or from N-1 to 0, for example, N-1, N-2…0, or from 2N to N+1, for example, 2N, 2N-1…N+1.

[0045] For example, taking a first string that includes a timestamp and an auto-incrementing sequence number, in a scenario where short links are generated in batches, the auto-incrementing sequence number can range from 1 to N, and the timestamp can be the current processing time, or "taken" the time of generation (i.e., the timestamp at the time the short code is generated). That is, for each short link, one auto-incrementing sequence number and one timestamp are taken. The timestamp can be at the millisecond level, so each short link has a different timestamp. One timestamp (or auto-incrementing sequence number, or auto-decrementing sequence number, or random number, or node identifier) ​​corresponds to one short link, and one short link is contained in one SMS message.

[0046] In some embodiments, the above Figure 1 S102 can also be implemented in the following ways. For example... Figure 2 As shown, Figure 2 This is a flowchart of another short link generation method provided in the embodiments of this application.

[0047] S1021. In a one-to-one correspondence manner, add the N first strings, N second strings and long link information together to obtain N original strings.

[0048] In this embodiment, the operational factors (including continuous factors and random factors) and long link information are added together. The output result (i.e., the original string) can be the concatenation of the two strings in sequence. For application scenarios where the long link information includes a single long link, this long link is added to each of the first strings in the continuous factors and each of the second strings in the random factors, resulting in N original strings. For application scenarios where the long link information includes N long links, each long link is added one-to-one to each of the first strings in the continuous factors and each of the second strings in the random factors, resulting in N original strings.

[0049] S1022. Map N original strings to obtain N short codes.

[0050] In this embodiment, each original string is mapped (e.g., through hashing) to obtain short codes. Hash operation (Hash) refers to hashing or mapping, used to transform an input of arbitrary length into a fixed-length output through a hash algorithm. For example, a hash operation yields an 8-byte decimal number, corresponding to 64 bits, which can be applied to a 64-bit processor. For instance, this embodiment can use the C++11 Hash function to map N original strings to obtain N short codes.

[0051] By obtaining the operation factors (including continuous factors and random factors), the business page information (i.e. long link information) is added to the operation factors to obtain N original strings (srcSample); srcSample combines the business page information and the operation factors, which improves the dispersion of srcSample; then, after performing a hash operation on srcSample, N short codes are obtained.

[0052] For example, the following are string concatenated: business-related page information (long link or long link ID or mini-program ID, etc.), node identifier (node ​​number of the machine where the service program that processes the business request is located), millisecond-level timestamp, auto-incrementing sequence number (from 1 to N), and 8-byte random number (corresponding to 64 bits). The result of the concatenation (i.e., N original strings) is then hashed to obtain an 8-byte decimal number (i.e., the short code is an 8-byte decimal number).

[0053] In this embodiment, each first string, each second string, and the long link information are added one-to-one to obtain N original strings. The first strings exhibit regularity, and the second strings exhibit continuity, thus improving the randomness and discreteness of the resulting original strings. Then, a hash operation is performed on the N original strings to obtain N short codes, each short code being a decimal number of the same byte (e.g., 8 bytes or 4 bytes). Because the original strings after addition are random and discrete, the short codes obtained through hashing reduce the probability of hash collisions. In other words, adding a factor before hashing results in higher dispersion and more uniform hash values ​​in the case of batch requests, compared to performing hashing directly without adding a factor, thus reducing the probability of hash collisions.

[0054] In some embodiments, the short code is in decimal; the above Figure 1 S103 may also include S1031-S1033. For example... Figure 3 As shown, Figure 3 This is a flowchart of another short link generation method provided in the embodiments of this application.

[0055] S1031. Convert the N short codes to their bases to obtain N candidate short links. The N candidate short links are in base M, where M is an integer greater than ten.

[0056] In this embodiment, the short code is decimal, and the candidate short links can be base-66, base-62, or other bases greater than 10. This embodiment does not impose any restrictions on this. The generated short codes are converted to different bases to obtain the candidate short links. The conversion of decimal numbers to base-66 uses the "divide by 66 and take the remainder, then arrange in reverse order" method, as follows: Divide the decimal number by 66 to obtain a quotient and a remainder; then divide the quotient by 66 again to obtain another quotient and a remainder, and so on, until the quotient is zero. Then, the first remainder obtained is taken as the least significant bit of the base-66 number, and the last remainder obtained is taken as the most significant bit of the base-66 number, and so on, to form the candidate short links. For example, convert the generated short code length (5-8 digits) to base 66 (including characters such as: az, AZ, 0-9, "-", "_", ".", "~") and take the remainder of the maximum value. Taking decimal A as a decimal number (i.e., short code) as an example, decimalA = decimal%66 to the power of (5 to 8). Then, convert decimalA into a base 66 number short code URL of 5 to 8 digits, padding with 0s in the high bits if the length is insufficient.

[0057] For example, after hashing the above N original strings (srcSample), N short codes are obtained, and then short code conversion is performed to obtain short code URLs (corresponding to candidate short links). That is, hashing srcSample yields a decimal number, which is then converted to base-66 (or base-62, which only includes the letters and numbers mentioned above, excluding the four characters), resulting in a base-66 value (corresponding to candidate short links). Finally, any links that are not long enough are padded with leading zeros.

[0058] S1032. By deduplicating the N candidate short links, N unique initial short links are generated.

[0059] In this embodiment, although the probability of hash collisions can be greatly reduced by adding operation factors for string concatenation and hashing, a small number of duplicate short links may still be stored. Therefore, deduplication needs to be performed locally. Candidate short links (short code URLs) are added to the deduplication set. The newly created deduplication set is empty. As short code URLs are added, the data increases, and newly added short code URLs are deduplicated with previously added short code URLs. Duplicate short code URLs are filtered out (i.e., the later-generated short code URL among every two or more mutually duplicated short code URLs). These duplicate short code URLs are then added again to a continuous factor (the continuous factor can be N+1, N+2, etc.) and a random factor to obtain a new string. A hash operation is performed on the new string to obtain a new short code. The new short code is converted to its base to obtain a new short code URL. The new short code URL is then added to the deduplication set until all short code URLs in the deduplication set are different, resulting in N unique initial short links. N unique initial short links refer to N distinct initial short links. Local deduplication only removes duplicates from the short URLs generated in this instance. Since the number of duplicates is small, it is more efficient.

[0060] For example, after local deduplication, for the filtered duplicate short code URLs, obtain the operation factor (including continuous factor and random factor), where N continues to increment, for example, N+1, N+2...; add the duplicate short code URL to the operation factor to obtain a new string (new srcSample); perform a hash operation on the new string (new srcSample) to obtain a new short code, and perform short code conversion to obtain a new short code URL. Repeat the above steps until no duplicate short code URLs appear, ensuring the uniqueness of the deduplicated short code URLs, and obtain N initial short links.

[0061] S1033. Based on the N initial short links and the database, perform deduplication to obtain N target short links. The database is used to store the index of local short links.

[0062] In this embodiment, a batch interface is called to request the insertion of N initial short links into a database. This database stores an index of local short links. The database adds an index to the successfully inserted initial short links and returns insertion identification information for each initial short link. For short links that fail to insert, the short link service platform repeats the following steps: adding the failed short links to a continuous factor (the continuous factor can be N+X+1, N+X+2…X, where X represents the number of sequence numbers used in the deduplication process in step S1032 above) and a random factor to obtain a new string; performing a hash operation on the new string to obtain a new short code; converting the new short code's base to obtain a new short code URL; and continuing to insert the new short code URLs into the database until the database returns insertion identification information for all short code URLs, indicating that all short code URLs have been successfully inserted, resulting in N target short links.

[0063] For example, the batch interface is called to insert the generated initial short links into a predefined database. For short links that fail to insert, a calculation factor (including continuous and random factors) is obtained, where N continues to increment, for example, N+X+1, N+X+2, ... The short links that failed to insert are added to the calculation factor to obtain a new string. This new string is then hashed to obtain a new short code, which is then converted to obtain a new short code URL. The above steps are repeated until all newly generated short code URLs are successfully inserted into the predefined database, resulting in N target short links.

[0064] It should be noted that the database is simply a repository for storing short links. The database has a unique index, and a failed insertion indicates that the inserted short link is a duplicate of a local short link in the database. The database can be a separate database from the short link server corresponding to the short link service platform, and can communicate with the short link service platform, or it can be located within the short link server. This embodiment of the application does not impose any restrictions on this.

[0065] In this embodiment, N short codes are converted to their bases to obtain N candidate short links. By deduplicating the N candidate short links, duplicate short links can be regenerated, improving the effectiveness of the N initial short links. Deduplication is then performed on the N initial short links and the database, ensuring that all short links are successfully inserted into the database, resulting in N target short links, further improving the effectiveness of the short links.

[0066] In some embodiments, the continuous factor further includes a second string sequence, which comprises a plurality of third strings in a regular pattern; the above Figure 3S1032 can also be implemented in the following way: Take N candidate short links as short links to be deduplicated; select at least one first short link without duplicates and at least one second short link with duplicates from the short links to be deduplicated, and determine each first short link as an initial short link; add the unused third string in the second string sequence to at least one second short link one by one to obtain at least one first deduplicated string, and take the group of third strings that have been added as the used third string; generate at least one third short link based on at least one first deduplicated string; if there are no duplicate short links among at least one third short link and at least one first short link, then determine each third short link as an initial short link; if there are duplicate short links among at least one third short link and at least one first short link, then take at least one third short link as a short link to be deduplicated, and return to the step of selecting at least one first short link without duplicates and at least one second short link with duplicates from the short links to be deduplicated, until there are no duplicate short links among the short links to be deduplicated, thus obtaining N initial short links.

[0067] In this embodiment, among N candidate short links, at least one first short link that is not duplicated and at least one second short link that is duplicated are selected; at least one third string in the second string sequence is added to the string corresponding to at least one second short link to obtain at least one first deduplicated string; at least one third short link is generated based on at least one first deduplicated string, and the selection is continued in at least one first short link and at least one third short link until no duplicate short links can be selected, thus obtaining N initial short links.

[0068] If a duplicate short link is found when filtering between at least one first short link and at least one third short link, then continue to perform the above steps of adding each unused third string in the second string sequence to the string corresponding to each duplicate short link to obtain each deduplicated string; and generating each new short link based on each deduplicated string, until no duplicate short links can be found, resulting in N initial short links.

[0069] In this embodiment of the application, if there are no duplicate short links among the N candidate short links, then the N candidate short links are used as N initial short links. That is, if there are no duplicate short links among the short links to be deduplicated, then each short link among the short links to be deduplicated is determined as an initial short link.

[0070] It should be noted that the occurrence of at least one duplicate second short link can be any of the candidate short links among two or more mutually duplicate candidate short links, or it can be at least one candidate short link generated later among two or more mutually duplicate candidate short links. This application embodiment does not limit this.

[0071] For example, taking a first string sequence containing N auto-incrementing indices (1, 2...N), a second string sequence containing multiple auto-incrementing indices (N+1, N+2...), and at least four second short links as an example: First, the N candidate short links are used as deduplicated short links. From these, (N-4) first short links that do not contain duplicates and four second short links that contain duplicates are selected, and each first short link is determined as an initial short link. Second, the auto-incrementing indices (N+1, N+2, N+3, N+4) in the second string sequence are sequentially added to the four second short links one by one to obtain four first deduplicated strings. Third, four third short links are generated based on the four first deduplicated strings. Fourth, if there are no duplicate short links among the four third short links and the (N-4) first short links, each third short link is determined as an initial short link, thus obtaining N initial short links. Fifth, if there are duplicate short links among the 4 third short links and (N-4) first short links, then the 4 third short links are taken as the short links to be deduplicated, and the process is returned to the first step until there are no duplicate short links among the short links to be deduplicated, thus obtaining N initial short links.

[0072] In this embodiment, the generated candidate short links are added to the deduplication set. The newly created deduplication set is empty. As candidate short links are added, the data increases, and newly added candidate short links are deduplicated with previously added candidate short links. Duplicate candidate short links (i.e., the later-added candidate short link among every two or more mutually duplicate candidate short links) are filtered out. These duplicate candidate short links are then added again to the continuous factor and the random factor to obtain the first deduplication string. The first deduplication string is hashed to obtain the first deduplication short code. The first deduplication short code is converted to its base to obtain the third short link. The third short link is then added to the deduplication set until all short links in the deduplication set are different, resulting in N unique initial short links, thereby improving the effectiveness of the N initial short links.

[0073] In some embodiments, the step of generating at least one third short link based on at least one first deduplication string can also be implemented in the following way: mapping at least one first deduplication string to obtain at least one first deduplication short code; performing a base conversion on the at least one first deduplication short code to obtain at least one third short link.

[0074] In this embodiment, each first deduplication string is mapped (e.g., by hashing). The C++11 Hash function can be used to map the first deduplication string to obtain a first deduplication short code. At least one first deduplication short code is a decimal number of the same byte size (e.g., 8 bytes or 4 bytes). Since the first deduplication short code is decimal, the third short link can be base-66 or base-62, or any other base greater than 10. The first deduplication short code is converted to its base to obtain the third short link.

[0075] The mapping process for each first deduplicated string to obtain each first deduplicated short code can be found in the description of S1022 above, and will not be repeated here. The radix conversion process for each first deduplicated short code to obtain each third short link can be found in the description of S1031 above, and will not be repeated here.

[0076] In some embodiments, the above Figure 3 S1033 can also be implemented in the following way: Request the insertion of N initial short links into the database; receive the insertion identifier information returned by the database, which carries the identifiers of the successfully inserted initial short links among the N initial short links; based on the insertion identifier information, determine the successfully inserted fourth short link and the failed inserted fifth short link from the N initial short links; generate deduplicated short links based on the second string sequence and the fifth short link; continue to request the insertion of deduplicated short links into the database until successful insertion, obtaining the successfully inserted sixth short link; determine N target short links based on the sixth short link and the fourth short link.

[0077] In this embodiment, the short link service platform initiates an insertion request to the database to insert N initial short links. It also receives insertion identifier information returned by the database; the ID returned by the database is the ID of the successfully inserted short link. Each short link inserted into the database automatically generates an ID. When a batch of short links (i.e., N initial short links) is inserted into the database, only the IDs of successfully inserted short links are returned. Based on this ID, the specific short link is retrieved and designated as the successfully inserted short link (i.e., the fourth successfully inserted short link). This also allows for the filtering of short links that failed to be inserted (i.e., the fifth failed short link). For each failed fifth short link, it is added to an unused third string in the second string sequence to obtain a second deduplication string. The resulting third string group is then designated as the used third string. Based on the second deduplication string, deduplicated short links are generated, and the short link service platform continues to request the insertion of deduplicated short links into the database. If the insertion identifier information returned by the database indicates that all deduplicated short links have been successfully inserted, then the short link designated as the fourth short link and the short links designated as deduplicated short links are designated as N target short links. If the successfully inserted short links and the failed short links are determined from the deduplicated short links based on the insertion identifier information returned by the database, then for the failed short links, the process returns to the step of adding the third string that was not used in the second string sequence, until all of them are successfully inserted into the database, resulting in N target short links.

[0078] It should be noted that the number of short links that fail to be inserted can be one or more, and the number of short links that are successfully inserted can also be one or more. Here, short links that fail to be inserted are referred to as the fourth short link, and short links that are successfully inserted are referred to as the fifth short link.

[0079] In this embodiment, the short link service platform requests to insert N initial short links into the database; and receives insertion identifier information returned by the database. Based on the insertion identifier information, it determines the fourth short link that was successfully inserted, and treats the other short links among the N initial short links as the fifth short links that failed to be inserted. For the fifth short link that failed to be inserted, it is necessary to regenerate deduplicated short links; and continue to request to insert deduplicated short links into the database until the insertion is successful, thereby obtaining N target short links. The N target short links are short links that have been deduplicated and successfully inserted, thus improving the effectiveness of the target short links.

[0080] In some embodiments, the fifth short link includes at least one; the step of generating deduplicated short links based on the second string sequence and the fifth short link described above can also be implemented in the following manner: Unused third strings in the second string sequence are sequentially added to at least one fifth short link to obtain at least one second deduplicated string; at least one second deduplicated string is mapped to obtain at least one second deduplicated short code; the at least one second deduplicated short code is converted to a different base to obtain at least one deduplicated short link.

[0081] In this embodiment, the third string included in the second string sequence has been used in the deduplication process of N candidate short links, and these used third strings are considered as the third strings that have already been used. During the current database insertion loop, unused third strings are selected sequentially from the second string sequence and added one by one to the string corresponding to each fifth short link to obtain the respective second deduplication strings.

[0082] In this embodiment, each second deduplication string is mapped (e.g., by hashing). The C++11 Hash function can be used to map the second deduplication string to obtain a second deduplication short code. At least one second deduplication short code is a decimal number of the same byte size (e.g., 8 bytes or 4 bytes). While the second deduplication short code is decimal, the deduplication short link can be base-66 or base-62, or any other base greater than 10. Converting the second deduplication short code to its base yields the deduplication short link.

[0083] The mapping process for each second deduplication string to obtain each second deduplication short code can be found in the description of S1022 above, and will not be repeated here. The radix conversion process for each second deduplication short code to obtain each deduplication short link can be found in the description of S1031 above, and will not be repeated here.

[0084] In some embodiments, in the above Figure 1 Following S103, this short link generation method may further include the following steps: storing the index relationship between N target short links and long link information in a database.

[0085] In this embodiment, the database is used to store the index of local short links. After obtaining N target short links, the database stores the index relationship between the N target short links and long link information. For application scenarios where the long link information includes a single long link, the database stores the index relationship between the N target short links and that long link. For application scenarios where the long link information includes N long links, the database stores a one-to-one correspondence between the target short links and the long links. This ensures that when a short link is clicked or viewed, it can jump to the page of the corresponding long link. That is, clicking the short link will jump to the business page of the long link. The business page information includes one of the following: long link, long link ID, mini-program ID, etc., improving the convenience of business services.

[0086] In some embodiments, in the above Figure 1 Following S103, this short link generation method may also include the following steps: generating N short link URLs based on N target short links and a preset domain name or the service domain name carried in the business request; and sending the N short link URLs to the user terminal.

[0087] In this embodiment, the preset domain name can be a default domain name, which can be appropriately configured by those skilled in the art based on actual conditions. For example, it can be the domain name of the short link server corresponding to the short link service platform. Taking the short link https: / / suo.nz / 378IQe as an example, "suo.nz" is the short domain name (the domain name of the short link server corresponding to the short link service platform), and "378IQe" is the specific short link. The service domain name carried in the business request can be the service domain name set by the user, for example, the service domain name related to the long link information in the business request.

[0088] The target short link returned by the database is combined with the domain name (preset domain name or service domain name carried in the business request) to form a complete SMS (i.e., short link URL). N short link URLs are returned to the user terminal, which refers to the terminal or server used by the user (e.g., merchant) who has the need to generate short links in batches.

[0089] It should be noted that multiple short domains are generated using their own URI addresses, and different short domains can have the same URI. In other words, short links (short URIs) under different short domains may be the same, but after adding the default domain or the service domain carried in the business request, the resulting short link URLs will be different.

[0090] After deduplication and successful insertion of the short code, the target short link is obtained. This target short link is then mapped to a predetermined short domain name (e.g., the domain name of the short link server) to generate a short link URL, which is returned to the user. The target short links are batch-obtained after mapping with continuous and random factors and deduplication, increasing the dispersion of the results and reducing the probability of hash collisions in scenarios with large batches of short link requests, thus improving the effectiveness of the short links. Based on this, the embodiments of this application also improve the effectiveness of the short link URLs.

[0091] The following will describe an exemplary application of the embodiments of this application in a real-world application scenario.

[0092] For example, the process of generating short links is illustrated by using business page information to represent long link information and URIs or short code URLs to represent short links. Figure 4 As shown, Figure 4 This is a flowchart of another short link generation method provided in the embodiments of this application, including S201-S206.

[0093] S201. Call the API interface to generate N short links.

[0094] The short link service platform receives short link generation requests from users and calls API interfaces based on the requests.

[0095] S202. Add the business page information and the operation factor to the string to obtain srcSample; perform a hash operation on srcSample and then perform short code conversion to obtain a short code URL, resulting in N URIs.

[0096] Obtain the operation factor. The random factor includes at least one of the following: random number, node number (service program number); the continuous factor includes at least one of the following: timestamp, auto-incrementing sequence number (1-N).

[0097] For example, taking a business page with information including URL, URL ID, and Mini Program ID as an example, we use URL / URL ID / Mini Program ID + service program number + millisecond-level timestamp + auto-incrementing sequence number (from 1 to N) + 8-byte random number to obtain srcSample. We then hash srcSample (using the C++11 hash function) to obtain an 8-byte decimal number decimal. Next, we convert the generated short code length (5-8 digits) to base 66 (az, AZ, 0-9, "-", ".", "_", "~") and take the remainder of the maximum value, i.e., decimalA = decimal % 66 to the power of (5-8). Then, we convert decimalA into a base 66 short code URL, padding with high-order digits if the length is insufficient. We repeat this process N times to obtain N URIs (also called short code URLs, corresponding to N candidate short links), where the auto-incrementing sequence number accumulates from 1 to N.

[0098] S203. Add the generated N URIs to a deduplication set. If duplicates are generated locally, continue to generate new URIs for the duplicate URIs using the method in S202 (the sequence number continues to accumulate) until no duplicates are generated locally, and obtain N initial short links.

[0099] Create a local deduplication set and add the generated short code URLs to the deduplication set for deduplication.

[0100] S204. Insert the generated N initial short links into the database using the batch interface, and determine whether the insertion was successful.

[0101] The database creates a unique index based on the domain name and short code. A batch API is called to insert the generated short links into the pre-defined database, and the insertion is checked for success. If successful, proceed to step S206; otherwise, proceed to step S205.

[0102] S205. Based on the ID returned by the database, call the database batch query interface to query the successfully inserted short links, then compare it with the local dataset to find out which short links failed to be inserted. Regenerate short codes (increment the sequence number) for the failed short links, and return to S204 until the insertion is successful.

[0103] For short links that fail to be inserted, repeat the above steps of adding with a random factor, hashing, and converting the number base until the newly generated short link is successfully inserted into the predetermined database, resulting in N target short links.

[0104] S206. Add the pre-defined short domain name to the N target short links and return them to the user.

[0105] The deduplicated and successfully inserted short URLs (i.e., N target short links) are combined with the predetermined short domain names to generate N short link URLs; the N short link URLs in the database are returned to the user.

[0106] This example demonstrates how to perform hash operations with an added operation factor for batch generation of short links. This results in higher dispersion of the results, reducing the probability of hash collisions. Furthermore, the steps of deduplication using a local deduplication set and successful insertion into the database improve the effectiveness of the short links.

[0107] Based on the short link generation method provided in the above embodiments Figure 5 This is a schematic diagram of a short link generation device provided in an embodiment of this application. This device can be implemented as part or all of a computer device by software, hardware, or a combination of both. See also... Figure 5 The short link generation device 50 (applied to the aforementioned short link service platform) includes: a receiving module 501, a generation module 502, and a deduplication module 503;

[0108] The receiving module 501 is used to receive a service request from the user terminal. The service request carries long connection information and is used to request the generation of N short connections, where N is an integer greater than 1.

[0109] The generation module 502 is used to generate N short codes based on the continuous factor, the random factor and the long link information. Each short code is a string. The continuous factor includes a first string sequence, which includes N first strings with regularity. The random factor includes N second strings with randomness.

[0110] The deduplication module 503 is used to perform deduplication processing on the N short codes and generate N target short links based on the deduplication processing results.

[0111] Optionally, the first string sequence includes at least one of the following: a timestamp sequence, a first auto-incrementing sequence, and a first auto-decrementing sequence, wherein the timestamp sequence includes the generation timestamps of each short code to be generated; and the random factor includes at least one of the following: a random number and a node identifier corresponding to the node used to run the service request.

[0112] Optionally, the generation module 502 is further configured to add the N first strings, the N second strings, and the long link information in a one-to-one correspondence manner to obtain N original strings; and to map the N original strings to obtain the N short codes.

[0113] Optionally, the short code is in decimal;

[0114] The deduplication module 503 is further configured to perform a base conversion on the N short codes to obtain N candidate short links, wherein the N candidate short links are in base M, and M is an integer greater than ten; by performing deduplication processing on the N candidate short links, N unique initial short links are generated; and by performing deduplication processing on the N initial short links and the database, the N target short links are obtained, wherein the database is used to store the index of local short links.

[0115] Optionally, the continuous factor further includes a second string sequence, which includes a plurality of third strings with a regularity;

[0116] The deduplication module 503 is further configured to: use the N candidate short links as short links to be deduplicated; select at least one first short link that does not have duplicates and at least one second short link that has duplicates from the short links to be deduplicated, and determine each first short link as the initial short link; add the unused third string in the second string sequence to each of the at least one second short link in turn to obtain at least one first deduplicated string, and take the group of third strings that have been added as the used third string; generate at least one third short link based on the at least one first deduplicated string; if there are no duplicate short links among the at least one third short link and the at least one first short link, then determine each third short link as the initial short link; if there are duplicate short links among the at least one third short link and the at least one first short link, then use the at least one third short link as a short link to be deduplicated, and return to the step of selecting at least one first short link that does not have duplicates and at least one second short link that has duplicates from the short links to be deduplicated, until there are no duplicate short links among the short links to be deduplicated, thus obtaining the N initial short links.

[0117] Optionally, the deduplication module 503 is further configured to map the at least one first deduplication string to obtain at least one first deduplication short code; and to perform a base conversion on the at least one first deduplication short code to obtain the at least one third short link.

[0118] Optionally, the deduplication module 503 is further configured to: request the insertion of the N initial short links into the database; receive insertion identification information returned by the database, the insertion identification information carrying the identifiers of the successfully inserted initial short links among the N initial short links; determine the successfully inserted fourth short link and the failed inserted fifth short link from the N initial short links based on the insertion identification information; generate deduplicated short links based on the second string sequence and the fifth short link; continue to request the insertion of the deduplicated short links into the database until successful insertion, obtaining the successfully inserted sixth short link; and determine the N target short links based on the sixth short link and the fourth short link.

[0119] Optionally, the deduplication module 503 is further configured to add the unused third string in the second string sequence to the at least one fifth short link in turn to obtain at least one second deduplication string; map the at least one second deduplication string to obtain at least one second deduplication short code; and perform a base conversion on the at least one second deduplication short code to obtain at least one deduplication short link.

[0120] Optionally, the short link generation device 50 also includes a storage module 504;

[0121] The storage module 504 is also used to store the index relationship between the N target short links and the long link information in the database.

[0122] Optionally, the short link generation device 50 also includes a sending module 505;

[0123] The generation module 502 is also used to generate N short link URLs based on the N target short links and the preset domain name or the service domain name carried by the business request.

[0124] The sending module 505 is used to send the N short URLs to the user terminal.

[0125] It should be noted that the short link generation device provided in the above embodiments is only illustrated by the division of the above functional modules when generating short links. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0126] The functional units and modules in the above embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of the embodiments of this application.

[0127] The short link generation device and the short link generation method provided in the above embodiments belong to the same concept. The specific working process and technical effects of the units and modules in the above embodiments can be found in the method embodiments section, and will not be repeated here.

[0128] Based on the short link generation method provided in the above embodiments Figure 6This application provides a schematic diagram of the structure of a computer device, as shown in the embodiment of the present application. Figure 6 As shown, the computer device 60 (also known as a short link service platform) includes: a processor 601, a memory 602, and a computer program 603 stored in the memory 602 and executable on the processor 601. When the processor 601 executes the computer program 603, it implements the steps in the short link generation method in the above embodiments.

[0129] Computer device 60 can be a general-purpose computer device or a special-purpose computer device. In specific implementations, computer device 60 can be a desktop computer, portable computer, network server, handheld computer, mobile phone, tablet computer, wireless terminal device, communication equipment, or embedded device. This application embodiment does not limit the type of computer device 60. Those skilled in the art will understand that... Figure 6 The computer device 60 is merely an example and does not constitute a limitation on the computer device 60. It may include more or fewer components than shown, or combine certain components, or different components, such as input / output devices, network access devices, etc.

[0130] Processor 601 can be a Central Processing Unit (CPU), or it can be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor.

[0131] In some embodiments, memory 602 may be an internal storage unit of computer device 60, such as a hard disk or RAM of computer device 60. In other embodiments, memory 602 may be an external storage device of computer device 60, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., provided on computer device 60. Furthermore, memory 602 may include both internal and external storage units of computer device 60. Memory 602 is used to store operating systems, applications, boot loaders, data, and other programs. Memory 602 may also be used to temporarily store data that has been output or will be output.

[0132] This application also provides a computer device, which includes: at least one processor, a memory, and a computer program stored in the memory and executable on the at least one processor, wherein the processor executes the computer program to implement the steps in any of the above method embodiments.

[0133] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, can implement the steps in the various method embodiments described above.

[0134] This application provides a computer program product that, when run on a computer, causes the computer to perform the steps described in the various method embodiments above.

[0135] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the above method embodiments of this application can be implemented by a computer program instructing related hardware. This computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or some intermediate form. The computer-readable medium can include at least: any entity or device capable of carrying the computer program code to a photographing device / terminal device, a recording medium, a computer memory, ROM (Read-Only Memory), RAM (Random Access Memory), CD-ROM (Compact Disc Read-Only Memory), magnetic tape, floppy disk, and optical data storage devices. The computer-readable storage medium mentioned in this application can be a non-volatile storage medium; in other words, it can be a non-transient storage medium.

[0136] It should be understood that all or part of the steps of the above embodiments can be implemented by software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented in whole or in part as a computer program product. The computer program product includes one or more computer instructions. The computer instructions can be stored in the above-described computer-readable storage medium.

[0137] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0138] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0139] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.

Claims

1. A method for generating short links, characterized in that, The method is applied to scenarios involving the batch generation of short links; the method includes: Receive a service request from the user, the service request carrying long link information, the service request being used to request the generation of N short links based on a long link or to generate N corresponding short links based on N long links, where N is an integer greater than 1; Based on the continuous factor, the random factor, and the long link information, N short codes are generated, each short code being a string. The continuous factor includes a first string sequence, which includes N first strings with a regularity. The random factor includes N second strings with randomness. The N short codes are deduplicated, and N target short links are generated based on the deduplication results. Wherein, the short codes are in decimal; the step of deduplication based on the N short codes, and generating N target short links based on the deduplication result, includes: The N short codes are converted to different bases to obtain N candidate short links; the N candidate short links are in base M, where M is an integer greater than ten; By deduplicating the N candidate short links, for duplicate candidate short links, new candidate short links are regenerated based on the duplicate candidate short links, the continuity factor, and the random factor, until N initial short links without duplication are obtained. The N initial short links are inserted into the database. For any initial short links that fail to be inserted, new initial short links are generated based on the failed initial short links, the continuous factor, and the random factor, until the insertion is successful, thus obtaining the N target short links. The database is used to store the index of local short links.

2. The method as described in claim 1, characterized in that, The first string sequence includes at least one of the following: a timestamp sequence, a first auto-incrementing sequence, and a first auto-decrementing sequence, wherein the timestamp sequence includes the generation timestamps of each short code to be generated; the random factor includes at least one of the following: a random number and a node identifier corresponding to the node used to run the service request.

3. The method as described in claim 1, characterized in that, The step of generating N short codes based on the continuous factor, the random factor, and the long link information includes: In a one-to-one correspondence manner, the N first strings, the N second strings, and the long link information are added together to obtain N original strings; The N original strings are mapped to obtain the N short codes.

4. The method according to any one of claims 1-3, characterized in that, The continuous factor also includes a second string sequence, which comprises a plurality of third strings in a regular pattern; The process of deduplicating the N candidate short links, and for duplicate candidate short links, regenerating new candidate short links based on the duplicate candidate short links, the continuity factor, and the random factor, until N initial short links without duplication are obtained, includes: The N candidate short links are used as short links to be deduplicated. At least one first short link that does not have duplicates and at least one second short link that has duplicates are selected from the short links to be deduplicated. Each first short link is determined as the initial short link. The unused third string in the second string sequence is added to the at least one second short link one by one to obtain at least one first deduplication string, and the group of third strings that are added is taken as the used third string; Based on the at least one first deduplication string, generate at least one third short link; If there are no duplicate short links among the at least one third short link and the at least one first short link, then each third short link is determined as the initial short link; If there are duplicate short links among the at least one third short link and the at least one first short link, then the at least one third short link is taken as the short link to be deduplicated, and the process returns to the step of filtering out at least one first short link that does not have duplicates and at least one second short link that has duplicates from the short links to be deduplicated, until there are no duplicate short links among the short links to be deduplicated, thus obtaining the N initial short links.

5. The method according to any one of claims 1-3, characterized in that, The process involves inserting the N initial short links into the database. For any initial short links that fail to insert, new initial short links are generated based on the failed initial short links, the continuous factor, and the random factor, until insertion is successful, resulting in the N target short links. Request the insertion of the N initial short links into the database; Receive the insertion identifier information returned by the database, wherein the insertion identifier information carries the identifier of the successfully inserted initial short link among the N initial short links; Based on the insertion identifier information, the fourth short link that was successfully inserted and the fifth short link that failed to be inserted are determined from the N initial short links; Generate deduplicated short links based on the second string sequence and the fifth short link; Continue to request the insertion of the deduplicated short link into the database until the insertion is successful, and obtain the sixth short link that has been successfully inserted. Based on the sixth short link and the fourth short link, the N target short links are determined.

6. The method according to any one of claims 1-3, characterized in that, After performing deduplication processing on the N short codes and generating N target short links based on the deduplication results, the process further includes: Based on the N target short links and the preset domain name or the service domain name carried in the business request, generate N short link URLs respectively; Send the N shortened URLs to the user's client.

7. A short link generation device, characterized in that, The device is designed for scenarios involving the batch generation of short links; it includes: The receiving module is used to receive service requests from the user terminal. The service requests carry long link information. The service requests are used to request the generation of N short links based on a long link or to generate N corresponding short links based on N long links, where N is an integer greater than 1. The generation module is used to generate N short codes based on the continuous factor, the random factor, and the long link information. Each short code is a string. The continuous factor includes a first string sequence, which includes N first strings with a regularity. The random factor includes N second strings with randomness. The short codes are in decimal. The deduplication module is used to perform deduplication processing on the N short codes and generate N target short links based on the deduplication processing results. The deduplication module is further used to perform a base conversion on the N short codes to obtain N candidate short links; the N candidate short links are in base M, where M is an integer greater than ten; by performing deduplication on the N candidate short links, for duplicate candidate short links, new candidate short links are regenerated based on the duplicate candidate short links, the continuity factor, and the random factor, until N non-duplicate initial short links are obtained; the N initial short links are inserted into the database, and for initial short links that fail to be inserted, new initial short links are regenerated based on the initial short links that fail to be inserted, the continuity factor, and the random factor, until insertion is successful, resulting in the N target short links; the database is used to store the index of local short links.

8. A computer device, characterized in that, The computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the method as described in any one of claims 1-6.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the method as described in any one of claims 1-6.

Citation Information

Patent Citations

  • Short link generation method and device and server

    CN110134889A

  • Short link generation method and device, electronic device and storage medium

    CN113420238A