[go: up one dir, main page]

WO2022242678A1 - Short link generation method and apparatus, device, and storage medium - Google Patents

Short link generation method and apparatus, device, and storage medium Download PDF

Info

Publication number
WO2022242678A1
WO2022242678A1 PCT/CN2022/093562 CN2022093562W WO2022242678A1 WO 2022242678 A1 WO2022242678 A1 WO 2022242678A1 CN 2022093562 W CN2022093562 W CN 2022093562W WO 2022242678 A1 WO2022242678 A1 WO 2022242678A1
Authority
WO
WIPO (PCT)
Prior art keywords
short link
target number
message
number segment
segment
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Ceased
Application number
PCT/CN2022/093562
Other languages
French (fr)
Chinese (zh)
Inventor
燕昆鹏
王金川
黄大烨
王建波
柴春燕
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Wodong Tianjun Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Publication of WO2022242678A1 publication Critical patent/WO2022242678A1/en
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/955Retrieval from the web using information identifiers, e.g. uniform resource locators [URL]
    • G06F16/9558Details of hyperlinks; Management of linked annotations
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems
    • G06F16/252Integrating or interfacing systems involving database management systems between a Database Management System and a front-end application
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q30/00Commerce
    • G06Q30/06Buying, selling or leasing transactions
    • G06Q30/0601Electronic shopping [e-shopping]
    • G06Q30/0641Electronic shopping [e-shopping] utilising user interfaces specially adapted for shopping
    • G06Q30/0643Electronic shopping [e-shopping] utilising user interfaces specially adapted for shopping graphically representing goods, e.g. 3D product representation

Definitions

  • the present application relates to the field of short link processing, and relates to but not limited to a method, device, device and storage medium for generating a short link.
  • MD5 Message-Digest Algorithm
  • the present application provides a method, device, device and storage medium for generating short links, which can increase the speed of generating short links.
  • the embodiment of the present application provides a method for generating a short link, the method comprising:
  • the minimum value of the target number segment is the same as the maximum value of the previous number segment of the target number segment, and the maximum value of the target number segment is the minimum value of the subsequent number segment of the target number segment
  • the values are the same, and the target number segment includes the first number of numbers
  • the expanded target number segment includes a second number of numbers, and the second number is greater than the first number
  • the target number is converted to determine the short link.
  • the embodiment of the present application provides a short link generating device, the device comprising:
  • An acquisition unit configured to acquire a target number segment; the minimum value of the target number segment is the same as the maximum value of the previous number segment of the target number segment, and the maximum value of the target number segment is the same as the maximum value of the target number segment The minimum value of a number segment is the same, and the target number segment includes the first number of numbers;
  • the processing unit is configured to extend the minimum value and maximum value of the target number segment to obtain an extended target number segment, the extended target number segment includes a second number of numbers, and the second number is greater than said first quantity;
  • a determination unit configured to determine a target number from said second number of numbers
  • the determining unit is further configured to convert the target number to determine a short link.
  • the embodiment of the present application provides an electronic device, a memory, a processor, and a computer program stored on the memory and operable on the processor, and the above-mentioned short link generation method is realized when the processor executes the computer program .
  • the embodiment of the present application provides a storage medium on which a computer program is stored, and when the computer program is executed by a processor, the above method for generating a short link is realized.
  • Fig. 1 is a kind of short link generating system provided by the embodiment of the present application.
  • FIG. 2 is an optional schematic flowchart of a method for generating a short link provided in an embodiment of the present application
  • FIG. 3 is an optional schematic flowchart of a method for generating a short link provided in an embodiment of the present application
  • FIG. 4 is a schematic flow diagram of an optional hot backup provided by the embodiment of the present application.
  • FIG. 5 is a schematic diagram of the principle of the signal generator provided by the embodiment of the present application.
  • Figure 6 is a schematic diagram of the principle of obtaining a number by the number issuer provided in the embodiment of the present application
  • FIG. 7 is a schematic flow diagram of an optional storage and hot backup short link provided by the embodiment of the present application.
  • FIG. 8 is a schematic structural diagram of an optional short link generation device provided by an embodiment of the present application.
  • FIG. 9 is a schematic structural diagram of an optional electronic device provided by an embodiment of the present application.
  • Embodiments of the present application may provide a short link generation method and device, a device (such as an electronic device) and a storage medium (such as a computer-readable storage medium).
  • a short link generation method and device such as an electronic device
  • a storage medium such as a computer-readable storage medium.
  • the method for generating a short link can be realized by using a short link generating device.
  • a link refers to a connection relationship from a webpage to a target, where the target can be another webpage, or a different location on the same webpage, or a picture, a file, etc.
  • Short link a category of links, wherein a short link usually consists of 7 characters or less than 7 characters.
  • Message Queue is a queue that can transmit data.
  • the short link generating method of the embodiment of the present application can be applied to the short link generating system 100 shown in FIG. 1 .
  • the server 10 and the client 20 communicate through the network 30 .
  • the server 10 After determining the short link, the server 10 sends the determined short link to the client 20 through the network 30 .
  • An embodiment of the present application provides a method for generating a short link, and the method is applied to a device for generating a short link.
  • the functions realized by the short link generation device can be realized by the processor in the server calling the program code, of course the program code can be stored in the memory, it can be seen that the server at least includes a processor and a memory.
  • Fig. 2 is a schematic diagram of the implementation flow of a short link generation method provided in the embodiment of the present application. The method is applied to the server, as shown in Fig. 2, and the method may include the following steps:
  • the server acquires a target number segment.
  • the minimum value of the target number segment is the same as the maximum value of the previous number segment of the target number segment
  • the maximum value of the target number segment is the same as the minimum value of the subsequent number segment of the target number segment
  • the The target number segment includes a first number of numbers.
  • Each number segment includes a segment of continuous positive integers.
  • the first number is 10, and the number segment [0, 10] includes a segment of continuous positive integers from 0 to 10.
  • the server may include: a central number segment generator and a code generator, wherein the central number segment generator is used to generate multiple number segments, and the code generator is used to obtain a number segment from the multiple number segments As the target number segment, the target number segment is expanded, and the expanded target number segment is sent to the number sender.
  • the central number segment generator After the central number segment generator sends out a certain number of number segments, it will continue to generate new number segments. In an example, after the central number segment generator sends out ten number segments, for example, [0,10], ..., [90,100], the central number segment generator will continue to generate new number segments [100 , 110].
  • the above S201 includes: the central number segment generator generates multiple number segments, and the code generator takes one number segment from the multiple number segments as the target number segment.
  • the multiple number segments generated by the central number segment generator include: 5 number segments are [0,10], [10,20], [20,30], [30,40], [40 , 60] these 5 number segments; the code generator takes a number segment from these 5 number segments, for example, number segment [10, 20], and uses this number segment [10, 20] as the target number segment.
  • the previous number section of the target number section is [0, 10], wherein the minimum number of the number section [0, 10] The value is 0, and the maximum value is 10; the next number segment of the target number segment is [20, 30], wherein, the minimum value of the number segment [20, 30] is 20, and the maximum value is 30; among them, the target number segment The minimum value of is 10, which is the same as the maximum value 10 of the previous segment [0, 10], and the maximum value of the target segment is 20, which is the same as the minimum value 20 of the subsequent segment [20, 30].
  • the server extends the minimum value and maximum value of the target number segment to obtain an extended target number segment, and the extended target number segment includes a second number of numbers.
  • the second quantity is greater than the first quantity.
  • the code generator expands the minimum value and maximum value of the target number segment, which may be multiplied by a coefficient for the minimum value of the target number segment, and multiplied by a coefficient for the maximum value of the target number segment, thereby obtaining the extended
  • the target number segment after the expansion, the target number segment after the expansion includes the number of the second quantity, and the target number segment after the expansion is sent to the number sender.
  • the embodiment of the present application does not limit the values of the coefficients.
  • the factor can be 10000 or 20000.
  • the target number segment is [10, 20]
  • the minimum value of the target number segment is multiplied by 10000
  • the minimum value of the extended target number segment is 100000
  • the maximum value of the target number segment is multiplied by 20
  • the maximum value of the expanded target number segment is 200000
  • the expanded target number segment is [100000, 200000]
  • the expanded target number segment includes numbers with a second quantity of 100000.
  • the server determines a target number from the second number of numbers.
  • the server may further include: a number sender, through which the target number is determined from the second number of numbers.
  • the number issuer selects a number from 100,000 numbers ranging from 100,000 to 200,000 as the target number, for example, selects 100,000 as the target number.
  • the server may include multiple number issuers, wherein, when multiple number issuers apply to obtain the number segments at the same time, the orthogonality of the number segments obtained by the number issuers can be ensured through distributed locks, thereby ensuring The target number segments obtained by each of the multiple signal issuers are orthogonal.
  • the code generator can take the next number segment that can be issued from the central number segment generator.
  • the server converts the target number to determine the short link.
  • the target number is converted by the sender to determine the short link.
  • the short link can be a character string.
  • the target number is 10000, and the number sender converts 10000 to determine the short link.
  • a short link generation method provided in an embodiment of the present application is to obtain a target number segment, the minimum value of the target number segment is the same as the maximum value of the previous number segment of the target number segment, and the maximum value of the target number segment The same as the minimum value of the next number segment of the target number segment, the target number segment includes a first number of numbers; expanding the minimum and maximum values of the target number segment to obtain a second number of numbers; Determining a target number from the second number of numbers; converting the target number to determine a short link.
  • the target number segment can be determined from a plurality of number segments first, and then a target number can be determined from the target number segment, the target number is converted to determine the short link, therefore, it is possible to directly Converting the target number to determine the short link does not need to go through tedious steps to convert the long link into a short link, so that the link generation process can be shortened, and the short link generation speed can be improved.
  • the above S201 includes:
  • the server determines whether the number of numbers cached locally is smaller than a preset threshold.
  • the embodiment of the present application does not limit the value of the preset threshold.
  • the preset threshold may be 10000 or 20000.
  • the server before obtaining the target number segment, the server needs to first determine whether the number of locally cached numbers is less than the preset threshold. If the number of locally cached numbers is less than or equal to the preset threshold, it means that the original locally cached The number of numbers is small. At this time, it is necessary to obtain the target number segment, expand the obtained target number segment, and determine the target number from the expanded target number segment, so as to convert the target number and determine the short link.
  • the method for generating a short link further includes: if the number of locally cached numbers is greater than a preset threshold, the server determines the target number from the locally cached numbers.
  • the server can directly determine the target number from the locally cached numbers. Obtain the target number section again, and expand the target number section, and then determine the target number from the expanded target number section.
  • the above S204 includes:
  • the server performs a modulus on the target number to obtain a modulo result.
  • the modulus result includes: at least one modulo parameter.
  • the server performs modulo acquisition of the target number, which may be modulo acquisition of the target number to a modulo coefficient.
  • the embodiment of the present application does not limit the modulo coefficient.
  • the modulo factor can be 62 or other numbers.
  • the target number is 10000, and the target number 10000 is moduloed to 62 to obtain, wherein, the obtained modulus result includes: at least one modulo parameter, and the at least one modulo parameter includes: 18, 37, 2, 0, 0, 0.
  • the server determines a character corresponding to each of the modulo parameters in the at least one modulo parameter.
  • At least one of the characters constitutes the short link.
  • the character corresponding to each modulus parameter in the at least one modulus parameter can be determined according to the correspondence table formed by the correspondence between the modulus parameter and the character.
  • the correspondence table may be as shown in Table 1.
  • the first line is a part of the modulus parameters
  • the second line is the character corresponding to the first line of the modulo parameter
  • the third line is a part of the modulus parameter
  • the fourth line is the character corresponding to the third line of the modulo parameter, and so on.
  • the target number is 10000, and 10000 is modulo 62, and the first modulus parameter obtained is 18.
  • the character corresponding to 18 can be obtained as 2;
  • the second modulo parameter obtained is 37, by looking up table 1, the character corresponding to 37 can be obtained as f;
  • the obtained third modulus parameter is 2, and by looking up table 1, the character corresponding to 2 can be obtained as 4;
  • the obtained fourth modulo parameter is 0, by looking up table 1, the character corresponding to 0 can be obtained as n;
  • the obtained fifth modulus parameter is 0, and by looking up table 1, the character corresponding to 0 can be obtained as n;
  • the obtained sixth modulo parameter is 0, by looking up table 1, the character corresponding to 0 can be obtained as n. Since the high bit is on the left, the character determined by the server corresponding to the 6 modulo parameters is nnn4f2.
  • the method of inserting visual interference bits and filtering strong regular character strings can be used, so that the character strings determined in the server are irregular, so that the terminal cannot obtain the generation method of the short link.
  • inserting a visual noise bit is inserting a visual noise bit in the determined character string.
  • the character "Q” is inserted into the second position of the determined character string "nnn4f2" to become “nQnn4f2".
  • the strong regular character string is filtered so that the character strings with consistent multiple digits such as "AAAAAA” and “AAAAAB” with strong regularity can be filtered and not sent to the terminal.
  • a distributed scenario can also be used, so that the acquired target numbers are different numbers In this way, since the obtained target numbers are numbers in different number segments, the difference between the obtained character strings will be relatively large, thereby making it difficult for the terminal to find the generation rules of the character strings.
  • the method further includes:
  • the server acquires a sorting policy.
  • the sorting strategy can be a sorting strategy for numbers in random order, or a sorting strategy for numbers from large to small, or a sorting strategy for numbers from small to large, which is not limited in the embodiment of the present application .
  • the server sorts the first number of numbers included in the target number segment based on the sorting policy.
  • the server may sort the first number of numbers included in the target number segment in random order.
  • sorting the numbers of the first quantity based on the sorting strategy can make the numbers after sorting different from the numbers before sorting, so that the sorting of the numbers of the first quantity included in the target number segment can be irregular, and then can make The terminal cannot obtain the generation method of the short link.
  • the method further includes:
  • the server stores the short link once, and stores it in the first storage area.
  • the first storage area is used to realize high-speed access to the short link.
  • the server stores the short link once, that is, the server stores the short link in the first storage area, wherein the first storage area can be a cache area, or a memory such as a remote dictionary service (Remote Dictionary Server, Redis) database, etc.
  • the database is not limited in this embodiment of the present application.
  • storing the generated short link for example, in Redis, can make the generated short link persistent.
  • the server performs secondary storage on the short link, and stores it in a second storage area.
  • the second storage area is used to realize the backup of the short link, for example, hot backup.
  • the secondary storage of the short link by the server is the hot backup of the short link by the server, and the hot backup of the short link to the second storage area, wherein the second storage area may be a storage area based on a distributed storage system, for example, It is a Hadoop-based database (Hadoop Database, HBase) database and a data warehouse tool (hive) database.
  • HBase Hadoop Database
  • HBase database has the characteristics of low cost, excellent performance, and easy expansion. It also supports fast insertion and query operations, which solves the system bottleneck that the relational database (MYSQL database) cannot adapt to massive data access.
  • the Hive database is used to store the full amount of data.
  • the short link is stored once, that is, the short link is stored in the cache, and high-speed access to the short link can be realized.
  • the full amount of short links can be stored twice, that is, Links are stored in disk, so that the security of full short links can be achieved.
  • the terminal When the terminal accesses the short link, it can first obtain the short link from the cache, and then obtain the short link from the disk if the short link is not obtained from the cache.
  • the least recently used (Least Recently Used, LRU) algorithm may be used to clean up infrequently used short links in the cache.
  • the basis for judging whether the short link in the cache is an infrequently used short link may be: the storage time of the short link, and/or the number of visits to the short link.
  • the short link is an uncommon short link; if the storage time of the short link is less than or equal to the preset storage time, it is determined that the short link is a commonly used short link.
  • the short link is a commonly used short link; if the number of visits to the short link is less than or equal to the preset number of visits, it is determined that the short link is an uncommon short link.
  • the method further includes:
  • the server sends the short link to the message queue MQ.
  • the server may further include: a message queue client, which controls the sending of the short link to the message queue server, where sending the short link to the message queue server can be regarded as sending the short link to the message queue MQ.
  • a message queue client which controls the sending of the short link to the message queue server, where sending the short link to the message queue server can be regarded as sending the short link to the message queue MQ.
  • the above S208 includes:
  • the server consumes the short link in the message queue, and stores the short link in the first database and the second database respectively.
  • the first database and the second database are different.
  • the first database may be an HBase database
  • the second database may be a Hive database.
  • the short link can be sent to the message queue, and then the short link can be stored in the first database and the second database through the message queue, so that the asynchronous decoupling of short link storage and hot backup can be realized, thereby shortening the Short link storage and hot backup time.
  • the above S209 includes:
  • the server judges whether the network of the message queue is abnormal.
  • the message queue client controls the short link to be sent to the message queue, if the message queue client has not received the message queue acknowledgment beyond the maximum waiting time If there is a reply to the short link, then the message queue client will judge that the network of the message queue is abnormal.
  • the short link needs to be sent to the reissue message list msgList through the reissue message thread, and then the reissue message list The short links in msgList are resent to the message queue.
  • the reissue message list msgList is a first-in-first-out queue implemented by Redis. It mainly stores short links that need to be reissued through the reissue message thread.
  • the short link is saved by the LPUSH instruction, and the short link is obtained by the RPOP instruction.
  • the sequence and efficiency of short link execution are guaranteed, and the time complexity of short link execution is O(1).
  • the time complexity O(1) indicates that the number of times of saving the short link through the LPUSH instruction, and the number of times of obtaining the short link through the RPOP instruction is a constant.
  • the resend message thread will regularly scan the resend message list msgList, and resend the short links that failed to be sent.
  • the first short link in the process of sending the first short link to the message queue, if the network of the message queue is abnormal, the first short link cannot be sent to the message queue. A short link is sent to the reissued message list, and then the first short link in the reissued message list is resent to the message queue.
  • the method further includes:
  • the server backs up the short links in the reissued message list to the backup message list through the backup message thread.
  • the backup message thread is used to back up the short link obtained by the reissue message thread, and the backup message thread will regularly scan the backup message list backUpList, and put the messages that have not been deleted for a long time into the reissue message list msgList , the backup message list backUpList is used to save the short link obtained through the backup message thread.
  • the server may atomically back up the short link in the reissue message list to the backup message list backUpList through the BRPOPLPUSH command of Redis.
  • atomically backing up the short link to the backup message list means backing up the integrity of the short link to the backup message list.
  • the server judges whether the short link in the resent message list is resent to the message queue.
  • the reissued message list msgList includes the second short link and the third short link, and the server backs up the second short link and the third short link to the backup message list backUpList through the backup message thread.
  • the backup message list backUpList includes: the second short link and the third short link. If the second short link in the reissued message list msgList is resent to the message queue, the second short link in the backup message list backUpList will be deleted; if the reissued message If the third short link in the list msgList is not resent to the message queue due to network abnormality, the third short link in the backup message list backUpList will be reserved. When the retention time is longer than the preset time length, the backup message list backUpList will be The third short link of is resent to the resend message list
  • the terminal 20 sends a short link generation request to the server 10, and the server 10 sends the short link to the terminal 20 based on the short link generation request sent by the terminal.
  • the server can complete the generation of the short link and the storage and hot backup of the short link by performing step A: generating the short link, step B: storing the short link, and step C: hot backing up the short link.
  • Step A generating a short link.
  • step A may include:
  • Step A1 the code generator acquires the target number segment.
  • the server includes: a central number segment generator, a code generator, and a number issuer.
  • the central number segment generator is used to generate a certain number of number segments, for example, 10 number segments, and each number segment is a number segment composed of a continuous positive integer.
  • the central number segment generator generates 10 number segments, for example, [0,10], [10,20], [20,30], ..., [m,k], [k,k+ 10], [k+10, n], ..., [90, 100], wherein, k, m and n are positive integers).
  • the code generator is used to take a number segment as a target number segment from a certain number of number segments generated by the central number segment generator, expand the target number segment, and send the expanded target number segment to the number sender.
  • the code generator selects [k, k+10] from the 10 number segments [0, 10], [10, 20], [20, 30], ..., [k, k+10] ] as the target number segment.
  • the target number segment is [k, k+10], and the target number segment is extended to obtain the extended target number segment as [k*10000, (k+10)*10000-1].
  • the number sender is used to select a number from the expanded target number segment as the target number.
  • step A2 the number issuer generates a short link through a short link generation algorithm.
  • the central number segment generator is used to generate number segments
  • the code generator is used to issue number segments.
  • Using the central number segment generator and code generator can decouple number segment generation and issuance, effectively sharing the central number segment generation
  • the service pressure of the server, the code generator depends on the central number segment generator, and the terminal obtains the string through the number generator. In this way, the service can have better horizontal scalability. When the number of visits is large, only horizontal expansion of the number is required.
  • the server can improve the throughput of the service. This design can support hundreds of millions of visits per day.
  • Step B store the short link.
  • step B refers to the explanation of S207 and S208 in the above-mentioned embodiment for details, which will not be repeated here.
  • the message queue is used to resolve the two storage operations. Coupling, for example, after storing the data in the cache, put the data directly into the message queue, and then the downstream data processing system of the message queue receives the data and writes the data to the disk. In this way, the time overhead of 2 times can be shortened to 1 time .
  • Step C performing hot backup on the short link.
  • the realization principle of the hot backup short link is mainly realized through the message queue, as shown in Figure 4, in the process of hot backup of the short link, the following steps are included:
  • the server sends the short link to the message queue MQ.
  • the message queue MQ receives the short link sent by the server, and stores the short link in the HBase database and the Hive database respectively.
  • FIG. 5 is a schematic diagram of the realization principle of the signal generator.
  • the functions performed by the signal device include: a first function D, a second function E, and a third function F; wherein, the first Function D is the function of obtaining numbers; the second function E is the function of number loading; the third function F is the function of disaster recovery and fault recovery.
  • the third function F is the function of disaster recovery and fault recovery.
  • the number issuer judges whether the number of locally cached numbers is greater than a preset threshold
  • the number issuer After submitting the number loading task to the linear pool, the number issuer can load the number asynchronously.
  • the signal transmitter acquires the minimum value X in the target number segment
  • the signal sender expands the minimum value and maximum value in the target number segment.
  • the target number segment after extending the minimum value and the maximum value in the target number segment may be: [X*100000,
  • the number issuing device saves all numbers to a local cache
  • the issuer After the issuer submits the disaster recovery task to the linear pool, the issuer can perform asynchronous disaster recovery.
  • the backup thread obtains the latest number value from Redis
  • the number value in Redis has not been deleted or tampered with, the number value in Redis can be updated to the disaster recovery database MySql.
  • the fault can be recovered by performing a rollback operation, the rollback operation is setting the latest number value in Redis to the number value of the disaster recovery database MySql+1000.
  • the number sending performance is less than 1ms, and due to the The number pools between are completely isolated. Therefore, the number issuer provided by the embodiment of the present application has the advantages of high concurrency, high performance, and high reliability.
  • the central number segment generator can generate multiple number segments and send multiple number segments to the number issuer.
  • the number issuer can obtain the number segment from the central number segment generator, and the number issuer can obtain the number After the segment, the digits of the number segment will be scrambled, and the sequence will be stored locally. Every time the number that can be used is taken out from the local storage as needed, after the number is taken out, it will be discarded and cannot be issued to the second terminal again. Out of order can make the terminal feel that the number segment is randomly generated when acquiring data. For example, the number segment obtained from the central number segment generator is [0, 9], then the local storage may be [7, 6, 0, 5, 2, 3, 4, 1, 8, 9] (random storage, also possibly another sequence).
  • the short link generation algorithm will be explained in detail below.
  • the number issuer ensures high-performance access to unique numbers, and what the short link generation algorithm needs to do is to ensure the unique mapping between the number and the short link.
  • the idea adopted by the short link generation algorithm is to convert decimal numbers into hexadecimal numbers, and use the modulus mapping method to generate a string with the same number of digits as the number of modulus, so as to realize the controllability of the length of the random string generation.
  • the short link generation algorithm includes the above-mentioned S204a and S204b.
  • S204a and S204b are the explanations of S204a and S204b in the above-mentioned embodiments, which will not be repeated here.
  • the processes of storing and hot backup short chains are asynchronously decoupled, so that system problems such as excessively long existing processes and non-core processes affecting the performance of the main process can be solved.
  • the short link and related data are stored in the distributed memory database Redis, and then the data is put into middleware such as message queue MQ, and the subsequent data backup is performed by the corresponding hot backup process.
  • middleware such as message queue MQ
  • the asynchronous decoupling of storage and hot backup of short links can be realized, so that the efficiency of short link generation can be realized.
  • the short link storage and hot backup mainly include two parts: asynchronous sending MQ message mechanism and failure message recovery mechanism.
  • asynchronous sending MQ message mechanism including:
  • the number generator generates a short link
  • the sender sends the short link to the message queue MQ;
  • the signal generator judges whether the MQ network is abnormal
  • the sender After sending the short link to the message queue MQ, the sender sends the short link to the HBase database and the Hive database respectively.
  • the backup message thread includes:
  • the asynchronous sending MQ message mechanism is mainly realized by means of the client (Client) related to MQ, and the sending result will call the callback function: the short link sent successfully can be written into HBase and Hive asynchronously; The short link can be saved to the resend message list msgList.
  • the failure message remediation mechanism is mainly used to solve the remediation when the MQ network is abnormal.
  • the MQ network anomaly will have a catastrophic impact on the system and will cause the overall short-chain service to be unavailable for a period of time. Therefore, we use it when the MQ network is abnormal. Fail fast strategy.
  • the fail-fast strategy can quickly give users feedback results without affecting the core process.
  • the reissued message list msgList and the backup message list backUpList are a first-in-first-out queue implemented using Redis. Messages are saved through the LPUSH instruction and obtained through the RPOP instruction, thereby ensuring the order and efficiency of message execution, and the execution time of messages is complex. The degree is O(1).
  • the reissued message list msgList mainly stores which messages need to be reissued through the reissued message thread; the backup message list backUpList mainly stores which reissued messages have been obtained by the reissued message thread, that is, the messages in the reissued message list are backup.
  • the resend message thread regularly scans the resend message list msgList, and resends the failed message. For example, when the reissued message list msgList is found to have message message1, the reissued message thread will delete message1 from the reissued message list msgList through the Redis BRPOPLPUSH command and atomically save it to the backup message list backUpList. If the resend message thread successfully sends MQ, delete message1 from the backup message list again; if the resend message thread crashes or fails to send MQ, it will not be processed.
  • the backup message thread regularly scans the backup message list backUpList, and puts the messages that have not been deleted for a long time into the reissued message list msgList. For example, if the above message1 crashes after being retrieved by the reissued message thread, message1 will not be deleted from the backup message list. At this time, the backup message thread will obtain message1. If the message creation time of message1 is greater than the set time threshold, for example , 30 minutes, the backup message thread will delete message1 from the backup message list backUpList through the Redis BRPOPLPUSH command and atomically save it to the reissue message list msgList.
  • the performance can be improved from the previous 17ms to 3ms by introducing a signal generator, optimized generation algorithm, asynchronous decoupled storage, and hot backup.
  • FIG. 8 is a short link generation device provided by the embodiment of the present application. As shown in FIG. 8, the short link generation device 800 includes:
  • the acquiring unit 801 is configured to acquire a target number segment; the minimum value of the target number segment is the same as the maximum value of the previous number segment of the target number segment, and the maximum value of the target number segment is the same as the target number segment The minimum value of the latter number segment is the same, and the target number segment includes the first number of numbers;
  • the processing unit 802 is configured to extend the minimum value and the maximum value of the target number segment to obtain an extended target number segment, and the extended target number segment includes a second number of numbers, and the second number is greater than said first quantity;
  • a determining unit 803 configured to determine a target number from the second number of numbers
  • the determining unit 803 is further configured to convert the target number to determine a short link.
  • the acquiring unit 801 is further configured to determine whether the number of locally cached numbers is less than a preset threshold; if the number of locally cached numbers is less than or equal to the preset threshold, acquire the target number segment.
  • the determining unit 803 is further configured to determine a target number from the locally cached numbers if the number of the locally cached numbers is greater than the preset threshold.
  • the determining unit 803 is further configured to take a modulo on the target number to obtain a modulo result, the modulo result including: at least one modulo parameter; determining the at least one modulo parameter Each of the characters corresponding to the modulo parameter; at least one of the characters constitutes the short link.
  • the device for generating short links further includes: a sorting unit; the acquiring unit 801 is also configured to acquire a sorting strategy; and the sorting unit is configured to sort the first number of the target number segments included in the target number segment based on the sorting strategy number to sort.
  • the device for generating a short link further includes: a storage unit; the storage unit is configured to store the short link once, and store it in the first storage area; the first storage area is used to realize the storage of the short link The high-speed access of the short link; the storage unit is also configured to store the short link twice in a second storage area; the second storage area is used to realize the backup of the short link.
  • the short link generation device further includes: a sending unit; the sending unit is configured to send the short link to a message queue; a storage unit is also configured to consume the short link in the message queue , respectively storing the short link in a first database and a second database, where the first database is different from the second database.
  • the sending unit is further configured to determine whether the network of the message queue is abnormal; if the network of the message queue is abnormal, send the short link to the reissue message list through the reissue message thread, and Resend the short links in the resent message list to the message queue.
  • the processing unit is further configured to back up the short link in the reissued message list to the backup message list through the backup message thread; determine whether the short link in the reissued message list is resent to the Message queue; if the short link in the reissued message list is resent to the message queue, delete the short link in the backup message list and the resent message queue in the reissued message list; if the If the short link in the reissued message list is not resent to the message queue, then the short link corresponding to the reissued message list in the backup message list is reserved, and when the retention time is longer than the preset time length, then Resend the short link in the backup message list to the reissue message list.
  • the embodiment of the present application also provides an electronic device, including a memory and a processor, the memory stores a computer program that can run on the processor, and the processor implements the short link provided in the above embodiment when executing the program generate method.
  • the electronic device may be a client or a server.
  • the embodiment of the present application also provides a storage medium, that is, a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the method for generating a short link provided in the above-mentioned embodiment is implemented.
  • FIG. 9 is a schematic diagram of a hardware entity of an electronic device according to an embodiment of the present application.
  • the electronic device 900 includes: a processor 901, at least one communication bus 902, and at least one external communication interface 904 and memory 905.
  • the communication bus 902 is configured to realize connection and communication among these components.
  • the electronic device 900 further includes: a user interface 903, wherein the user interface 903 may include a display screen, and the external communication interface 904 may include a standard wired interface and a wireless interface.
  • the memory 905 is configured to store instructions and applications executable by the processor 901, and can also cache data to be processed or processed by the processor 901 and various modules in the electronic device (for example, image data, audio data, voice communication data and video data) Communication data), which can be realized by flash memory (FLASH) or random access memory (Random Access Memory, RAM).
  • the disclosed devices and methods may be implemented in other ways.
  • the device embodiments described above are only illustrative.
  • the division of the units is only a logical function division.
  • the coupling, or direct coupling, or communication connection between the components shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be electrical, mechanical or other forms of.
  • the units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed to multiple network units; Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
  • each functional unit in each embodiment of the present application can be integrated into one processing unit, or each unit can be used as a single unit, or two or more units can be integrated into one unit; the above-mentioned integration
  • the unit can be realized in the form of hardware or in the form of hardware plus software functional unit.
  • the above-mentioned integrated units of the present application are realized in the form of software function modules and sold or used as independent products, they can also be stored in a computer-readable storage medium.
  • the computer software products are stored in a storage medium and include several instructions to make A computer device (which may be a personal computer, a server, or a network device, etc.) executes all or part of the methods described in the various embodiments of the present application.
  • the aforementioned storage medium includes various media capable of storing program codes such as removable storage devices, ROMs, magnetic disks or optical disks.

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Data Mining & Analysis (AREA)
  • Accounting & Taxation (AREA)
  • Finance (AREA)
  • Economics (AREA)
  • General Business, Economics & Management (AREA)
  • Strategic Management (AREA)
  • Marketing (AREA)
  • Development Economics (AREA)
  • Computing Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The present application discloses a short link generation method. The method comprises: acquiring a target number segment, the minimum value of the target number segment being the same as the maximum value of a previous number segment of the target number segment, the maximum value of the target number segment being the same as the minimum value of a next number segment of the target number segment, and the target number segment comprising a first number of numbers; expanding the minimum value and the maximum value of the target number segment to obtain an extended target number segment, the extended target number segment comprising a second number of numbers, and the second number being greater than the first number; determining a target number from the second number of numbers; and converting the target number to determine a short link. In addition, the present application further discloses a short link generation apparatus, an electronic device, and a storage medium.

Description

短链接生成方法、装置、设备及存储介质Short link generation method, device, equipment and storage medium

相关申请的交叉引用Cross References to Related Applications

本申请基于申请号为202110548216.1、申请日为2021年5月19日的中国专利申请提出,并要求该中国专利申请的优先权,该中国专利申请的全部内容在此以引入方式并入本申请。This application is based on a Chinese patent application with application number 202110548216.1 and a filing date of May 19, 2021, and claims the priority of this Chinese patent application. The entire content of this Chinese patent application is hereby incorporated into this application by reference.

技术领域technical field

本申请涉及短链接处理领域,涉及但不限于一种短链接生成方法、装置、设备及存储介质。The present application relates to the field of short link processing, and relates to but not limited to a method, device, device and storage medium for generating a short link.

背景技术Background technique

当电子商务公司之间的竞争日趋激烈化,为了简化内容界面和提升用户体验,电子商务公司通常会将长链接转换成短链接。When the competition among e-commerce companies is becoming increasingly fierce, in order to simplify the content interface and improve user experience, e-commerce companies usually convert long links into short links.

目前,电子商务公司通常是采用信息摘要算法(Message-Digest Algorithm,MD5)对加密串进行分段截取,然后结合移位操作和取模运算来将长链接转换成短链接,由于将长链接转换成短链接的流程较长,因此,现有技术中的短链接的生成速度慢。At present, e-commerce companies usually use Message-Digest Algorithm (MD5) to segment encrypted strings, and then combine shift operations and modulo operations to convert long links into short links. The process of forming a short link is relatively long, therefore, the generation speed of the short link in the prior art is slow.

发明内容Contents of the invention

本申请为解决相关技术中存在的至少一个问题而提供一种短链接生成方法、装置、设备及存储介质,能够提高短链接的生成速度。In order to solve at least one problem in the related art, the present application provides a method, device, device and storage medium for generating short links, which can increase the speed of generating short links.

本申请的技术方案是这样实现的:The technical scheme of the present application is realized like this:

第一方面,本申请实施例提供一种短链接生成方法,所述方法包括:In the first aspect, the embodiment of the present application provides a method for generating a short link, the method comprising:

获取目标号段;所述目标号段的最小值与所述目标号段的前一个号段的最大值相同,所述目标号段的最大值与所述目标号段的后一个号段的最小值相同,所述目标号段包括第一数量的号码;Obtain the target number segment; the minimum value of the target number segment is the same as the maximum value of the previous number segment of the target number segment, and the maximum value of the target number segment is the minimum value of the subsequent number segment of the target number segment The values are the same, and the target number segment includes the first number of numbers;

对所述目标号段的最小值和最大值进行扩展,得到扩展后的目标号段,所述扩展后的目标号段包括第二数量的号码,所述第二数量大于所述第一数量;Extending the minimum value and the maximum value of the target number segment to obtain an extended target number segment, the expanded target number segment includes a second number of numbers, and the second number is greater than the first number;

从所述第二数量的号码中确定目标号码;determining a target number from said second number of numbers;

对所述目标号码进行转换,确定短链接。The target number is converted to determine the short link.

第二方面,本申请实施例提供一种短链接生成装置,所述装置包括:In the second aspect, the embodiment of the present application provides a short link generating device, the device comprising:

获取单元,配置为获取目标号段;所述目标号段的最小值与所述目标号段的前一个号段的最大值相同,所述目标号段的最大值与所述目标号段的后一个号段的最小值相同,所述目标号段包括第一数量的号码;An acquisition unit configured to acquire a target number segment; the minimum value of the target number segment is the same as the maximum value of the previous number segment of the target number segment, and the maximum value of the target number segment is the same as the maximum value of the target number segment The minimum value of a number segment is the same, and the target number segment includes the first number of numbers;

处理单元,配置为对对所述目标号段的最小值和最大值进行扩展,得到扩展后的目标号段,所述扩展后的目标号段包括第二数量的号码,所述第二数量大于所述第一数量;The processing unit is configured to extend the minimum value and maximum value of the target number segment to obtain an extended target number segment, the extended target number segment includes a second number of numbers, and the second number is greater than said first quantity;

确定单元,配置为从所述第二数量的号码中确定目标号码;a determination unit configured to determine a target number from said second number of numbers;

所述确定单元,还配置为对所述目标号码进行转换,确定短链接。The determining unit is further configured to convert the target number to determine a short link.

第三方面,本申请实施例提供一种电子设备,存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现上述短链接生成方法。In the third aspect, the embodiment of the present application provides an electronic device, a memory, a processor, and a computer program stored on the memory and operable on the processor, and the above-mentioned short link generation method is realized when the processor executes the computer program .

第四方面,本申请实施例提供一种存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现上述短链接生成方法。In a fourth aspect, the embodiment of the present application provides a storage medium on which a computer program is stored, and when the computer program is executed by a processor, the above method for generating a short link is realized.

附图说明Description of drawings

图1为本申请实施例提供的一种短链接生成系统;Fig. 1 is a kind of short link generating system provided by the embodiment of the present application;

图2为本申请实施例提供的短链接生成方法的可选地流程示意图;FIG. 2 is an optional schematic flowchart of a method for generating a short link provided in an embodiment of the present application;

图3为本申请实施例提供的短链接生成方法的可选地流程示意图;FIG. 3 is an optional schematic flowchart of a method for generating a short link provided in an embodiment of the present application;

图4为本申请实施例提供的热备份的可选地流程示意图;FIG. 4 is a schematic flow diagram of an optional hot backup provided by the embodiment of the present application;

图5为本申请实施例提供的发号器的原理示意图;FIG. 5 is a schematic diagram of the principle of the signal generator provided by the embodiment of the present application;

图6为本申请实施例提供的发号器获取号码的原理示意图Figure 6 is a schematic diagram of the principle of obtaining a number by the number issuer provided in the embodiment of the present application

图7为本申请实施例提供的存储和热备份短链接的可选地流程示意图;FIG. 7 is a schematic flow diagram of an optional storage and hot backup short link provided by the embodiment of the present application;

图8为本申请实施例提供的短链接生成装置的可选地结构示意图;FIG. 8 is a schematic structural diagram of an optional short link generation device provided by an embodiment of the present application;

图9为本申请实施例提供的电子设备的可选地结构示意图。FIG. 9 is a schematic structural diagram of an optional electronic device provided by an embodiment of the present application.

具体实施方式Detailed ways

为使本申请实施例的目的、技术方案和优点更加清楚,下面将结合本申请实施例中的附图,对申请的具体技术方案做进一步详细描述。以下实施例用于说明本申请,但不用来限制本申请的范围。In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the specific technical solutions of the application will be further described in detail below in conjunction with the drawings in the embodiments of the present application. The following examples are used to illustrate the present application, but not to limit the scope of the present application.

本申请实施例可提供为短链接生成方法及装置、设备(例如电子设备)和存储介质(例如计算机可读存储介质)。实际应用中,短链接生成方法可利用短链接生成装置实现。Embodiments of the present application may provide a short link generation method and device, a device (such as an electronic device) and a storage medium (such as a computer-readable storage medium). In practical applications, the method for generating a short link can be realized by using a short link generating device.

除非另有定义,本文所使用的所有的技术和科学术语与属于本申请的技术领域的技术人员通常理解的含义相同。本文中在本申请的说明书中所使用的术语只是为了描述具体的实施例的目的,不是旨在于限制本申请。本文所使用的术语“和/或”包括一个或多个相关的所列项目的任意的和所有的组合。Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the technical field to which this application belongs. The terms used herein in the specification of the application are only for the purpose of describing specific embodiments, and are not intended to limit the application. As used herein, the term "and/or" includes any and all combinations of one or more of the associated listed items.

对本发明进行进一步详细说明之前,对本发明实施例中涉及的名词和术语进行说明,本发明实施例中涉及的名词和术语适用于如下的解释。Before the present invention is further described in detail, the nouns and terms involved in the embodiments of the present invention are described, and the nouns and terms involved in the embodiments of the present invention are applicable to the following explanations.

1)链接,是指从一个网页指向一个目标的连接关系,其中,目标可以是另一个网页,也可以是相同网页上的不同位置,还可以是图片、文件等。1) A link refers to a connection relationship from a webpage to a target, where the target can be another webpage, or a different location on the same webpage, or a picture, a file, etc.

2)短链接,链接的一种分类,其中,短链接通常由7个字符组成,或者由小于7个的字符组成。2) Short link, a category of links, wherein a short link usually consists of 7 characters or less than 7 characters.

3)消息队列(Message Queue,MQ),是一个能够传输数据的队列。3) Message Queue (MQ) is a queue that can transmit data.

本申请实施例的短链接生成方法可应用于图1所示的短链接生成系统100,如图1所示,该短链接生成系统100包括服务器10、客户端20和网络30。其中,服务器10和客户端20之间通过网络30进行通信。服务器10在确定短链接后,通过网络30将确定的短链接发送至客户端20。The short link generating method of the embodiment of the present application can be applied to the short link generating system 100 shown in FIG. 1 . As shown in FIG. Wherein, the server 10 and the client 20 communicate through the network 30 . After determining the short link, the server 10 sends the determined short link to the client 20 through the network 30 .

下面,结合图1所示的短链接生成系统的示意图,对本申请实施例提供的短链接生成方法、装置、设备及存储介质的各实施例进行说明。Below, with reference to the schematic diagram of the short link generation system shown in FIG. 1 , various embodiments of the short link generation method, device, device, and storage medium provided by the embodiments of the present application will be described.

本申请实施例提供一种短链接生成方法,该方法应用于短链接生成装置。该短链接生成装置所实现的功能可以通过服务器中的处理器调用程序代码来实现,当然程序代码可以保存在存储器中,可见,该服务器至少包括处理器和存储器。An embodiment of the present application provides a method for generating a short link, and the method is applied to a device for generating a short link. The functions realized by the short link generation device can be realized by the processor in the server calling the program code, of course the program code can be stored in the memory, it can be seen that the server at least includes a processor and a memory.

下面通过附图及具体实施例对本申请做进一步的详细说明。The present application will be further described in detail through the accompanying drawings and specific embodiments below.

图2为本申请实施例提供的一种短链接生成方法的实现流程示意图,该方法应用于服务器,如图2所示,该方法可以包括如下步骤:Fig. 2 is a schematic diagram of the implementation flow of a short link generation method provided in the embodiment of the present application. The method is applied to the server, as shown in Fig. 2, and the method may include the following steps:

S201、服务器获取目标号段。S201. The server acquires a target number segment.

其中,目标号段的最小值与所述目标号段的前一个号段的最大值相同,所述目标号段的最大值与所述目标号段的后一个号段的最小值相同,所述目标号段包括第一数量的号码。Wherein, the minimum value of the target number segment is the same as the maximum value of the previous number segment of the target number segment, the maximum value of the target number segment is the same as the minimum value of the subsequent number segment of the target number segment, and the The target number segment includes a first number of numbers.

在每个号段中,均包括一段连续的正整数。例如,第一数量为10,在号段[0,10]中,包括由0到10的一段连续的正整数。Each number segment includes a segment of continuous positive integers. For example, the first number is 10, and the number segment [0, 10] includes a segment of continuous positive integers from 0 to 10.

本申请实施例中,服务器可以包括:中央号段生成器和代码生成器,其中,中央号段生成器用于生成多个号段,代码生成器用于从该多个号段中拿取一个号段作为目标号段,对目标号段进行扩展,并将扩展后的目标号段发送给发号器。In the embodiment of the present application, the server may include: a central number segment generator and a code generator, wherein the central number segment generator is used to generate multiple number segments, and the code generator is used to obtain a number segment from the multiple number segments As the target number segment, the target number segment is expanded, and the expanded target number segment is sent to the number sender.

中央号段生成器在发出一定数量的号段后,会继续生成新的号段。在一示例中,中央号段生成器在发出十个号段,例如,[0,10]、……、[90,100]后,该中央号段生成器会继续生成新的号段[100,110]。After the central number segment generator sends out a certain number of number segments, it will continue to generate new number segments. In an example, after the central number segment generator sends out ten number segments, for example, [0,10], ..., [90,100], the central number segment generator will continue to generate new number segments [100 , 110].

本申请实施例中,上述S201包括:中央号段生成器生成多个号段,代码生成器从多个号段中拿取一个号段作为目标号段。In the embodiment of the present application, the above S201 includes: the central number segment generator generates multiple number segments, and the code generator takes one number segment from the multiple number segments as the target number segment.

在一示例中,中央号段生成器生成的多个号段,包括:5个号段为[0,10]、[10,20]、[20,30]、[30,40]、[40,60]这5个号段;代码生成器从这5个号段中拿取一个号段,例如,号段[10,20],并将该号段[10,20]作为目标号段。在目标号段[10,20]中,包括第一数量的号码,例如10个号码,该目标号段的前一个号段为[0,10],其中,号段[0,10]的最小值为0,最大值为10;该目标号段的后一个号段为[20,30],其中,号段[20,30]的最小值为20,最大值为30;其中,目标号段的最小值为10,与前一个号段[0,10]的最大值10相同,目标号段的最大值为20,与后一个号段[20,30]的最小值20相同。In an example, the multiple number segments generated by the central number segment generator include: 5 number segments are [0,10], [10,20], [20,30], [30,40], [40 , 60] these 5 number segments; the code generator takes a number segment from these 5 number segments, for example, number segment [10, 20], and uses this number segment [10, 20] as the target number segment. In the target number section [10, 20], including the number of the first quantity, such as 10 numbers, the previous number section of the target number section is [0, 10], wherein the minimum number of the number section [0, 10] The value is 0, and the maximum value is 10; the next number segment of the target number segment is [20, 30], wherein, the minimum value of the number segment [20, 30] is 20, and the maximum value is 30; among them, the target number segment The minimum value of is 10, which is the same as the maximum value 10 of the previous segment [0, 10], and the maximum value of the target segment is 20, which is the same as the minimum value 20 of the subsequent segment [20, 30].

S202、服务器对所述目标号段的最小值和最大值进行扩展,得到扩展后的目标号段,所述扩展 后的目标号段包括第二数量的号码。S202. The server extends the minimum value and maximum value of the target number segment to obtain an extended target number segment, and the extended target number segment includes a second number of numbers.

其中,第二数量大于第一数量。Wherein, the second quantity is greater than the first quantity.

这里,代码生成器对所述目标号段的最小值和最大值进行扩展,可以是对目标号段的最小值乘以一个系数,和对目标号段的最大值乘以一个系数,从而得到扩展后的目标号段,所述扩展后的目标号段包括第二数量的号码,并将扩展后的目标号段发送至发号器。Here, the code generator expands the minimum value and maximum value of the target number segment, which may be multiplied by a coefficient for the minimum value of the target number segment, and multiplied by a coefficient for the maximum value of the target number segment, thereby obtaining the extended The target number segment after the expansion, the target number segment after the expansion includes the number of the second quantity, and the target number segment after the expansion is sent to the number sender.

需要说明的是,本申请实施例不对系数的数值进行限定。例如,系数可以是10000,也可以是20000。It should be noted that the embodiment of the present application does not limit the values of the coefficients. For example, the factor can be 10000 or 20000.

在一示例中,目标号段为[10,20],对目标号段的最小值10乘以系数10000,得到扩展后的目标号段的最小值为100000,对目标号段的最大值20乘以系数10000,得到扩展后的目标号段的最大值为200000,这样,扩展后的目标号段为[100000,200000],该扩展后的目标号段包括第二数量为100000的号码。In an example, the target number segment is [10, 20], the minimum value of the target number segment is multiplied by 10000, and the minimum value of the extended target number segment is 100000, and the maximum value of the target number segment is multiplied by 20 With a coefficient of 10000, the maximum value of the expanded target number segment is 200000, thus, the expanded target number segment is [100000, 200000], and the expanded target number segment includes numbers with a second quantity of 100000.

S203、服务器从所述第二数量的号码中确定目标号码。S203. The server determines a target number from the second number of numbers.

这里,服务器还可以包括:发号器,通过发号器从第二数量的号码中确定目标号码。Here, the server may further include: a number sender, through which the target number is determined from the second number of numbers.

在一示例中,发号器从100000至200000这100000个号码中,选择一个号码作为目标号码,例如,选择100000作为目标号码。In an example, the number issuer selects a number from 100,000 numbers ranging from 100,000 to 200,000 as the target number, for example, selects 100,000 as the target number.

本申请实施例中,服务器可以包括多个发号器,其中,当多个发号器同时申请获取号段时,可以通过分布式锁确保发号器获取号段的正交性,进而可以保证多个发号器中的每个发号器获取的目标号段是正交的。In the embodiment of the present application, the server may include multiple number issuers, wherein, when multiple number issuers apply to obtain the number segments at the same time, the orthogonality of the number segments obtained by the number issuers can be ensured through distributed locks, thereby ensuring The target number segments obtained by each of the multiple signal issuers are orthogonal.

当目标号段中的号码发放完毕后,代码生成器可以再从中央号段生成器拿取下一个可以发放的号段。When the number in the target number segment has been issued, the code generator can take the next number segment that can be issued from the central number segment generator.

S204、服务器对所述目标号码进行转换,确定短链接。S204. The server converts the target number to determine the short link.

这里,通过发号器对目标号码进行转换,确定短链接。其中,短链接可以是一个字符串。Here, the target number is converted by the sender to determine the short link. Wherein, the short link can be a character string.

在一示例中,目标号码为10000,发号器对10000进行转换,确定短链接。In an example, the target number is 10000, and the number sender converts 10000 to determine the short link.

本申请实施例提供的一种短链接生成方法,获取目标号段,所述目标号段的最小值与所述目标号段的前一个号段的最大值相同,所述目标号段的最大值与所述目标号段的后一个号段的最小值相同,所述目标号段包括第一数量的号码;对所述目标号段的最小值和最大值进行扩展,得到第二数量的号码;从所述第二数量的号码中确定目标号码;对所述目标号码进行转换,确定短链接。这样,在确定短链接的过程中,由于可以先从多个号段中确定目标号段,再从目标号段中确定一个目标号码,对该目标号码进行转换,确定短链接,因此,可以直接对目标号码进行转换,确定短链接,不需要再通过繁琐的步骤将长链接转换为短链接了,从而可以缩短链接的生成流程,进而可以提高短链接的生成速度。A short link generation method provided in an embodiment of the present application is to obtain a target number segment, the minimum value of the target number segment is the same as the maximum value of the previous number segment of the target number segment, and the maximum value of the target number segment The same as the minimum value of the next number segment of the target number segment, the target number segment includes a first number of numbers; expanding the minimum and maximum values of the target number segment to obtain a second number of numbers; Determining a target number from the second number of numbers; converting the target number to determine a short link. In this way, in the process of determining the short link, since the target number segment can be determined from a plurality of number segments first, and then a target number can be determined from the target number segment, the target number is converted to determine the short link, therefore, it is possible to directly Converting the target number to determine the short link does not need to go through tedious steps to convert the long link into a short link, so that the link generation process can be shortened, and the short link generation speed can be improved.

在一些实施例中,上述S201包括:In some embodiments, the above S201 includes:

S201a、服务器判断本地缓存的号码的数量是否小于预设阈值。S201a. The server determines whether the number of numbers cached locally is smaller than a preset threshold.

需要说明的是,本申请实施例不对预设阈值的数值进行限制。例如,预设阈值可以为10000, 也可以为20000。It should be noted that, the embodiment of the present application does not limit the value of the preset threshold. For example, the preset threshold may be 10000 or 20000.

S201b、若所述本地缓存的号码的数量小于等于所述预设阈值,则获取目标号段。S201b. If the number of numbers cached locally is less than or equal to the preset threshold, acquire a target number segment.

本申请实施例中,在获取目标号段之前,服务器需要先判断本地缓存的号码的数量是否小于预设阈值,若本地缓存的号码的数量小于等于预设阈值,则说明原有的本地缓存的号码数量较少,此时需要获取目标号段,对获取到的目标号段进行扩展,并从扩展后的目标号段中确定目标号码,从而对目标号码进行转换,确定短链接。In this embodiment of the application, before obtaining the target number segment, the server needs to first determine whether the number of locally cached numbers is less than the preset threshold. If the number of locally cached numbers is less than or equal to the preset threshold, it means that the original locally cached The number of numbers is small. At this time, it is necessary to obtain the target number segment, expand the obtained target number segment, and determine the target number from the expanded target number segment, so as to convert the target number and determine the short link.

在一些实施例中,本申请实施例提供的短链接生成方法还包括:若本地缓存的号码的数量大于预设阈值,服务器则从本地缓存的号码中确定目标号码。In some embodiments, the method for generating a short link provided in the embodiment of the present application further includes: if the number of locally cached numbers is greater than a preset threshold, the server determines the target number from the locally cached numbers.

本申请实施例中,若本地缓存的号码的数量大于预设阈值,则说明原有的本地缓存的号码数量较多,能够使得服务器直接从本地缓存的号码中确定目标号码,此时就不需要再获取目标号段,并对目标号段进行扩展,再从扩展后的目标号段中确定目标号码了。In this embodiment of the application, if the number of locally cached numbers is greater than the preset threshold, it means that the number of original locally cached numbers is large, and the server can directly determine the target number from the locally cached numbers. Obtain the target number section again, and expand the target number section, and then determine the target number from the expanded target number section.

在一些实施例中,上述S204包括:In some embodiments, the above S204 includes:

S204a、服务器对所述目标号码进行取模,得到取模结果。S204a. The server performs a modulus on the target number to obtain a modulo result.

其中,所述取模结果包括:至少一个取模参数。Wherein, the modulus result includes: at least one modulo parameter.

这里,服务器将目标号码进行取模,可以是将目标号码对取模系数进行取模。Here, the server performs modulo acquisition of the target number, which may be modulo acquisition of the target number to a modulo coefficient.

需要说明的是,本申请实施例不对取模系数进行限制。例如,取模系数可以是62,也可以是其他数字。It should be noted that the embodiment of the present application does not limit the modulo coefficient. For example, the modulo factor can be 62 or other numbers.

在一示例中,目标号码为10000,将目标号码10000对62进行取模,得到,其中,得到的取模结果包括:至少一个取模参数,该至少一个取模参数,包括:18、37、2、0、0、0。In an example, the target number is 10000, and the target number 10000 is moduloed to 62 to obtain, wherein, the obtained modulus result includes: at least one modulo parameter, and the at least one modulo parameter includes: 18, 37, 2, 0, 0, 0.

S204b、服务器确定所述至少一个取模参数中的每一个所述取模参数对应的字符。S204b. The server determines a character corresponding to each of the modulo parameters in the at least one modulo parameter.

其中,至少一个所述字符组成所述短链接。Wherein, at least one of the characters constitutes the short link.

这里,可以根据取模参数与字符的对应关系所形成的对应关系表,确定至少一个取模参数中的每一个取模参数对应的字符。其中,对应关系表可如表1所示。Here, the character corresponding to each modulus parameter in the at least one modulus parameter can be determined according to the correspondence table formed by the correspondence between the modulus parameter and the character. Wherein, the correspondence table may be as shown in Table 1.

在表1所示对应关系表中,有a-z,A-Z,0-9共62个字符,每一个字符都有与其对应的取模参数。其中,第一行为一部分取模参数,第二行为与第一行的取模参数所对应的字符,第三行为一部分取模参数,第四行为与第三行的取模参数所对应的字符,以此类推。In the correspondence table shown in Table 1, there are a total of 62 characters including a-z, A-Z, and 0-9, and each character has a corresponding modulo parameter. Among them, the first line is a part of the modulus parameters, the second line is the character corresponding to the first line of the modulo parameter, the third line is a part of the modulus parameter, and the fourth line is the character corresponding to the third line of the modulo parameter, and so on.

表1、对应关系表示例Table 1. Example of correspondence table

00 11 22 33 44 55 66 77 88 99 NN 11 44 ZZ CC EE. LL Ff 00 cc 1010 1111 1212 1313 1414 1515 1616 1717 1818 1919 YY VV QQ sthe s 77 tt PP Oo 22 88 2020 21twenty one 22twenty two 23twenty three 24twenty four 2525 2626 2727 2828 2929 KK jj 99 uu ii Xx vv SS DD. TT 3030 3131 3232 3333 3434 3535 3636 3737 3838 3939

BB mm ww rr GG kk RR ff Uu aa 4040 4141 4242 4343 4444 4545 4646 4747 4848 4949 33 dd 55 BB WW ll NN II zz xx 5050 5151 5252 5353 5454 5555 5656 5757 5858 5959 AA Mm YY qq JJ GG Hh hh ee oo 6060 6161  the  the  the  the  the  the  the  the 66 PP  the  the  the  the  the  the  the  the

在一示例中,目标号码为10000,将10000对62取模,得到的第一个取模参数为18,通过查找表1,可以得到18对应的字符为2;得到的第二个取模参数为37,通过查找表1,可以得到37对应的字符为f;得到的第三个取模参数为2,通过查找表1,可以得到2对应的字符为4;得到的第四个取模参数为0,通过查找表1,可以得到0对应的字符为n;得到的第五个取模参数为0,通过查找表1,可以得到0对应的字符为n;得到的第六个取模参数为0,通过查找表1,可以得到0对应的字符为n。由于高位在左侧,因此,服务器确定的与6个取模参数对应的字符为nnn4f2。In an example, the target number is 10000, and 10000 is modulo 62, and the first modulus parameter obtained is 18. By looking up Table 1, the character corresponding to 18 can be obtained as 2; the second modulo parameter obtained is is 37, by looking up table 1, the character corresponding to 37 can be obtained as f; the obtained third modulus parameter is 2, and by looking up table 1, the character corresponding to 2 can be obtained as 4; the obtained fourth modulo parameter is 0, by looking up table 1, the character corresponding to 0 can be obtained as n; the obtained fifth modulus parameter is 0, and by looking up table 1, the character corresponding to 0 can be obtained as n; the obtained sixth modulo parameter is 0, by looking up table 1, the character corresponding to 0 can be obtained as n. Since the high bit is on the left, the character determined by the server corresponding to the 6 modulo parameters is nnn4f2.

需要说明的是,本申请实施例不对对应关系表中包括的字符进行限定,也可以根据业务场景用其他字符代替。It should be noted that the embodiments of the present application do not limit the characters included in the correspondence table, and may also be replaced by other characters according to business scenarios.

本申请实施例中,可以采用插入视觉干扰位和强规律字符串过滤的方法,使得在服务器中确定的字符串没有规律,这样,可以保证终端无法获取短链接的生成方式。In the embodiment of the present application, the method of inserting visual interference bits and filtering strong regular character strings can be used, so that the character strings determined in the server are irregular, so that the terminal cannot obtain the generation method of the short link.

在一示例中,插入视觉干扰位为在确定的字符串中插入一个视觉干扰位。例如,在确定的字符串“nnn4f2”的第二位插入字符“Q”,变成“nQnn4f2”。In an example, inserting a visual noise bit is inserting a visual noise bit in the determined character string. For example, the character "Q" is inserted into the second position of the determined character string "nnn4f2" to become "nQnn4f2".

在一示例中,强规律字符串过滤为在类似“AAAAAA”,“AAAAAB”等这种连续多位一致,规律性极强的字符串可以做过滤处理,不将其发送给终端。In an example, the strong regular character string is filtered so that the character strings with consistent multiple digits such as "AAAAAA" and "AAAAAB" with strong regularity can be filtered and not sent to the terminal.

本申请实施例中,为了使得终端无法获取短链接的生成方式,除了采用上述的插入视觉干扰位和强规律字符串过滤的方法外,还可以采用分布式场景,使得获取的目标号码为不同号段中的号码,这样,由于获取的目标号码为不同号段中的号码,因此,获取到的字符串的差距就会较大,从而可以使得终端难以发现字符串的生成规律。In the embodiment of this application, in order to make the terminal unable to obtain the short link generation method, in addition to the above-mentioned method of inserting visual interference bits and strong regular character string filtering, a distributed scenario can also be used, so that the acquired target numbers are different numbers In this way, since the obtained target numbers are numbers in different number segments, the difference between the obtained character strings will be relatively large, thereby making it difficult for the terminal to find the generation rules of the character strings.

在一些实施例中,在上述S201后,所述方法还包括:In some embodiments, after the above S201, the method further includes:

S205、服务器获取排序策略。S205. The server acquires a sorting policy.

这里,排序策略可以是对号码进行乱序排序的排序策略,也可以对号码进行从大到小的排序策略,还可以是对号码进行从小到大的排序策略,本申请实施例对此不作限制。Here, the sorting strategy can be a sorting strategy for numbers in random order, or a sorting strategy for numbers from large to small, or a sorting strategy for numbers from small to large, which is not limited in the embodiment of the present application .

S206、服务器基于所述排序策略将所述目标号段所包括的第一数量的号码进行排序。S206. The server sorts the first number of numbers included in the target number segment based on the sorting policy.

在一示例中,若排序策略为对号码进行乱序排序的排序策略,服务器则可以对目标号段所包括的第一数量的号码进行乱序排序。In an example, if the sorting strategy is a sorting strategy for numbers in random order, the server may sort the first number of numbers included in the target number segment in random order.

这样,基于排序策略对第一数量的号码进行排序,可以使得经过排序后的号码与排序前的号码不同,从而可以使得目标号段所包括的第一数量的号码的排序没有规律,进而可以使得终端无法获 取短链接的生成方式。In this way, sorting the numbers of the first quantity based on the sorting strategy can make the numbers after sorting different from the numbers before sorting, so that the sorting of the numbers of the first quantity included in the target number segment can be irregular, and then can make The terminal cannot obtain the generation method of the short link.

在一些实施例中,上述S204后,所述方法还包括:In some embodiments, after the above S204, the method further includes:

S207、服务器对所述短链接进行一次存储,存储至第一存储区域。S207. The server stores the short link once, and stores it in the first storage area.

其中,所述第一存储区域用于实现对所述短链接的高速存取。Wherein, the first storage area is used to realize high-speed access to the short link.

这里,服务器对短链接进行一次存储即为服务器将短链接存储至第一存储区域中,其中,第一存储区域可以是缓存区域,也可以是远程字典服务(Remote Dictionary Server,Redis)数据库等内存数据库,本申请实施例对此不作限制。Here, the server stores the short link once, that is, the server stores the short link in the first storage area, wherein the first storage area can be a cache area, or a memory such as a remote dictionary service (Remote Dictionary Server, Redis) database, etc. The database is not limited in this embodiment of the present application.

本申请实施例中,对生成的短链接进行存储,例如,存储在Redis中,可以使得生成的短链接具有持久化。In the embodiment of the present application, storing the generated short link, for example, in Redis, can make the generated short link persistent.

S208、服务器对所述短链接进行二次存储,存储至第二存储区域。S208. The server performs secondary storage on the short link, and stores it in a second storage area.

其中,所述第二存储区域用于实现对所述短链接的备份,例如,热备份。Wherein, the second storage area is used to realize the backup of the short link, for example, hot backup.

这里,服务器对短链接进行二次存储即为服务器对短链接进行热备份,将短链接热备份至第二存储区域,其中,第二存储区域可以是基于分布式存储系统的存储区域,例如可以是基于Hadoop的数据库(Hadoop Database,HBase)数据库和数据仓库工具(hive)数据库。其中,HBase数据库具备成本低廉、性能优良、极易扩展等特性,同时支持快速插入和查询操作,解决了关系型数据库(MYSQL数据库)无法适应海量数据存取的系统瓶颈。Hive数据库用于保存全量数据。Here, the secondary storage of the short link by the server is the hot backup of the short link by the server, and the hot backup of the short link to the second storage area, wherein the second storage area may be a storage area based on a distributed storage system, for example, It is a Hadoop-based database (Hadoop Database, HBase) database and a data warehouse tool (hive) database. Among them, the HBase database has the characteristics of low cost, excellent performance, and easy expansion. It also supports fast insertion and query operations, which solves the system bottleneck that the relational database (MYSQL database) cannot adapt to massive data access. The Hive database is used to store the full amount of data.

这样,对短链接进行一次存储,即将短链接存储至缓存中,可以实现对短链接的高速存取,在将短链接存储至缓存区域后,还可以对全量短链接进行二次存储,即将短链接存储至磁盘中,这样,可以实现全量短链接的安全性。In this way, the short link is stored once, that is, the short link is stored in the cache, and high-speed access to the short link can be realized. After the short link is stored in the cache area, the full amount of short links can be stored twice, that is, Links are stored in disk, so that the security of full short links can be achieved.

在终端访问短链接时,可以先从缓存中获取短链接,若没有从缓存中获取到短链接,再从磁盘中获取短链接。When the terminal accesses the short link, it can first obtain the short link from the cache, and then obtain the short link from the disk if the short link is not obtained from the cache.

本申请实施例中,可以采用最近最少使用(Least Recently Used,LRU)算法清理缓存中不常用的短链接。In the embodiment of the present application, the least recently used (Least Recently Used, LRU) algorithm may be used to clean up infrequently used short links in the cache.

这里,判断缓存中的短链接是否是不常用的短链接的判断依据可以为:短链接的保存时间,和/或,访问短链接的次数。Here, the basis for judging whether the short link in the cache is an infrequently used short link may be: the storage time of the short link, and/or the number of visits to the short link.

若短链接的保存时间大于预设保存时间,则判断短链接是不常用的短链接;若短链接的保存时间小于等于预设保存时间,则判断短链接是常用的短链接。If the storage time of the short link is greater than the preset storage time, it is determined that the short link is an uncommon short link; if the storage time of the short link is less than or equal to the preset storage time, it is determined that the short link is a commonly used short link.

若访问短链接的次数大于预设访问次数,则判断短链接是常用的短链接;若访问短链接的次数小于等于预设访问次数,则判断短链接是不常用的短链接。If the number of visits to the short link is greater than the preset number of visits, it is determined that the short link is a commonly used short link; if the number of visits to the short link is less than or equal to the preset number of visits, it is determined that the short link is an uncommon short link.

在一些实施例中,在上述S207之后,所述方法还包括:In some embodiments, after the above S207, the method further includes:

S209、服务器将所述短链接发送至消息队列MQ。S209. The server sends the short link to the message queue MQ.

这里,服务器还可以包括:消息队列客户端,消息队列客户端控制所述短链接发送至消息队列服务器,其中,将短链接发送至消息队列服务器即可认为将短链接发送至消息队列MQ。Here, the server may further include: a message queue client, which controls the sending of the short link to the message queue server, where sending the short link to the message queue server can be regarded as sending the short link to the message queue MQ.

服务器在将短链接发送至消息队列后,上述S208包括:After the server sends the short link to the message queue, the above S208 includes:

S208a、服务器消费所述消息队列中的所述短链接,分别将所述短链接存储至第一数据库和第二数据库。S208a. The server consumes the short link in the message queue, and stores the short link in the first database and the second database respectively.

其中,第一数据库和第二数据库不同。在一示例中,第一数据库可以是HBase数据库,第二数据库可以是Hive数据库。Wherein, the first database and the second database are different. In an example, the first database may be an HBase database, and the second database may be a Hive database.

本申请实施例中,可以将短链接发送至消息队列,再通过消息队列将短链接存储至第一数据库和第二数据库,从而可以实现对短链接存储和热备份的异步解耦,从而缩短对短链接进行存储和热备份的时间。In the embodiment of this application, the short link can be sent to the message queue, and then the short link can be stored in the first database and the second database through the message queue, so that the asynchronous decoupling of short link storage and hot backup can be realized, thereby shortening the Short link storage and hot backup time.

在一些实施例中,上述S209包括:In some embodiments, the above S209 includes:

S209a、服务器判断所述消息队列的网络是否异常。S209a. The server judges whether the network of the message queue is abnormal.

这里,消息队列客户端中的配置文件里设置有最长等待时间,消息队列客户端控制短链接发送至消息队列时,如果超过该最长等待时间消息队列客户端还没有收到消息队列确认收到短链接的回复,那么消息队列客户端将会判断消息队列的网络是异常的。Here, there is a maximum waiting time set in the configuration file of the message queue client. When the message queue client controls the short link to be sent to the message queue, if the message queue client has not received the message queue acknowledgment beyond the maximum waiting time If there is a reply to the short link, then the message queue client will judge that the network of the message queue is abnormal.

S209b、若所述消息队列的网络异常,则通过补发消息线程将所述短链接发送至补发消息列表,并将所述补发消息列表中的短链接重新发送至所述消息队列。S209b. If the network of the message queue is abnormal, send the short link to the reissue message list through the reissue message thread, and resend the short link in the reissue message list to the message queue.

本申请实施例中,若消息队列的网络异常,则说明服务器无法将短链接发送至消息队列,此时需要通过补发消息线程将短链接发送至补发消息列表msgList,再将补发消息列表msgList中的短链接重新发送至消息队列。In the embodiment of this application, if the network of the message queue is abnormal, it means that the server cannot send the short link to the message queue. At this time, the short link needs to be sent to the reissue message list msgList through the reissue message thread, and then the reissue message list The short links in msgList are resent to the message queue.

其中,补发消息列表msgList是使用Redis实现的一个先进先出队列,主要保存的是需要通过补发消息线程进行补发的短链接,通过LPUSH指令保存短链接,通过RPOP指令获取短链接,从而保证了短链接执行的顺序性以及高效性,短链接执行的时间复杂度为O(1)。其中,时间复杂度O(1)表示通过LPUSH指令保存短链接的次数,以及通过RPOP指令获取短链接的次数是一个常数。Among them, the reissue message list msgList is a first-in-first-out queue implemented by Redis. It mainly stores short links that need to be reissued through the reissue message thread. The short link is saved by the LPUSH instruction, and the short link is obtained by the RPOP instruction. The sequence and efficiency of short link execution are guaranteed, and the time complexity of short link execution is O(1). Wherein, the time complexity O(1) indicates that the number of times of saving the short link through the LPUSH instruction, and the number of times of obtaining the short link through the RPOP instruction is a constant.

补发消息线程会定时扫描补发消息列表msgList,对发送失败的短链接进行再次发送。The resend message thread will regularly scan the resend message list msgList, and resend the short links that failed to be sent.

在一示例中,在向消息队列发送第一短链接的过程中,若消息队列的网络异常,则会造成该第一短链接无法发送至消息队列,此时可通过补发消息线程将该第一短链接发送至补发消息列表,再将该补发消息列表中的第一短链接重新发送至消息队列。In an example, in the process of sending the first short link to the message queue, if the network of the message queue is abnormal, the first short link cannot be sent to the message queue. A short link is sent to the reissued message list, and then the first short link in the reissued message list is resent to the message queue.

在一些实施例中,在服务器通过补发消息线程将所述短链接发送至补发消息列表之后,所述方法还包括:In some embodiments, after the server sends the short link to the reissue message list through the reissue message thread, the method further includes:

S210、服务器通过备份消息线程,将所述补发消息列表中的短链接备份至备份消息列表。S210. The server backs up the short links in the reissued message list to the backup message list through the backup message thread.

本申请实施例中,备份消息线程用于对补发消息线程获取的短链接进行备份,且备份消息线程会定时扫描备份消息列表backUpList,把长时间未删除的消息重新放到补发消息列表msgList,备份消息列表backUpList用于保存通过备份消息线程获取的短链接。In the embodiment of this application, the backup message thread is used to back up the short link obtained by the reissue message thread, and the backup message thread will regularly scan the backup message list backUpList, and put the messages that have not been deleted for a long time into the reissue message list msgList , the backup message list backUpList is used to save the short link obtained through the backup message thread.

在一示例中,服务器可以通过Redis的BRPOPLPUSH命令,将补发消息列表中的短链接原子性的备份至备份消息列表backUpList。其中,将短链接原子性的备份至备份消息列表即为将短链接完整性的备份至备份消息列表。In an example, the server may atomically back up the short link in the reissue message list to the backup message list backUpList through the BRPOPLPUSH command of Redis. Wherein, atomically backing up the short link to the backup message list means backing up the integrity of the short link to the backup message list.

S211、服务器判断所述补发消息列表中的短链接是否重新发送至所述消息队列。S211. The server judges whether the short link in the resent message list is resent to the message queue.

S212、若所述补发消息列表中的短链接重新发送至所述消息队列,则将备份消息列表中的与所述补发消息列表中的重新发送至消息队列的短链接删除。S212. If the short link in the reissue message list is resent to the message queue, delete the short link in the backup message list and the resend message queue in the reissue message list.

S213、若所述补发消息列表中的短链接没有重新发送至所述消息队列,则对备份消息列表中的与所述补发消息列表中对应的短链接进行保留,当保留时长大于预设时间时,则将所述备份消息列表中的短链接重新发送至所述补发消息列表。S213. If the short link in the reissued message list is not resent to the message queue, reserve the short link in the backup message list corresponding to the reissued message list, and when the reserved time is longer than the preset time, resend the short link in the backup message list to the reissue message list.

在一示例中,补发消息列表msgList包括第二短链接和第三短链接,服务器通过备份消息线程,将第二短链接和第三短链接备份至备份消息列表backUpList,此时,备份消息列表backUpList包括:第二短链接和第三短链接,若补发消息列表msgList中的第二短链接重新发送至消息队列了,则将备份消息列表backUpList中的第二短链接删除;若补发消息列表msgList中的第三短链接因网络异常而没有重新发送至消息队列,则对备份消息列表backUpList中的第三短链接进行保留,当保留时长大于预设时长时,则将备份消息列表backUpList中的第三短链接重新发送至补发消息列表In an example, the reissued message list msgList includes the second short link and the third short link, and the server backs up the second short link and the third short link to the backup message list backUpList through the backup message thread. At this time, the backup message list backUpList includes: the second short link and the third short link. If the second short link in the reissued message list msgList is resent to the message queue, the second short link in the backup message list backUpList will be deleted; if the reissued message If the third short link in the list msgList is not resent to the message queue due to network abnormality, the third short link in the backup message list backUpList will be reserved. When the retention time is longer than the preset time length, the backup message list backUpList will be The third short link of is resent to the resend message list

msgList。msgList.

本申请实施例提供的短链接生成方法,如图3所示,终端20向服务器10发送短链接生成请求,服务器10基于终端发送的短链接生成请求,向终端20发送短链接。其中,服务器可以通过执行步骤A:生成短链接,步骤B:存储短链接,以及步骤C:热备份短链接,完成短链接的生成以及对短链接的存储和热备份。下面将分别对这三个功能进行详细介绍。In the short link generation method provided by the embodiment of the present application, as shown in FIG. 3 , the terminal 20 sends a short link generation request to the server 10, and the server 10 sends the short link to the terminal 20 based on the short link generation request sent by the terminal. Wherein, the server can complete the generation of the short link and the storage and hot backup of the short link by performing step A: generating the short link, step B: storing the short link, and step C: hot backing up the short link. These three functions will be described in detail below.

步骤A、生成短链接。Step A, generating a short link.

其中,步骤A可以包括:Wherein, step A may include:

步骤A1、代码生成器器获取目标号段。Step A1, the code generator acquires the target number segment.

本申请实施例中,服务器包括:中央号段生成器、代码生成器和发号器。其中,中央号段生成器用于生成一定数量的号段,例如,10个号段,每个号段是由一段连续的正整数组成的号码片段。In the embodiment of the present application, the server includes: a central number segment generator, a code generator, and a number issuer. Wherein, the central number segment generator is used to generate a certain number of number segments, for example, 10 number segments, and each number segment is a number segment composed of a continuous positive integer.

在一示例中,中央号段生成器生成10个号段,例如,[0,10]、[10,20]、[20,30]、……、[m,k]、[k,k+10]、[k+10,n]、……、[90,100],其中,k,m和n为正整数)。In one example, the central number segment generator generates 10 number segments, for example, [0,10], [10,20], [20,30], ..., [m,k], [k,k+ 10], [k+10, n], ..., [90, 100], wherein, k, m and n are positive integers).

代码生成器用于从中央号段生成器生成的一定数量的号段中拿取一个号段作为目标号段,对该目标号段进行扩展,并将扩展后的目标号段发送至发号器。The code generator is used to take a number segment as a target number segment from a certain number of number segments generated by the central number segment generator, expand the target number segment, and send the expanded target number segment to the number sender.

在一示例中,代码生成器从[0,10]、[10,20]、[20,30]、……、[k,k+10]这10个号段中选择[k,k+10]作为目标号段。In one example, the code generator selects [k, k+10] from the 10 number segments [0, 10], [10, 20], [20, 30], ..., [k, k+10] ] as the target number segment.

在一示例中,目标号段为[k,k+10],对目标号段进行扩展,得到扩展后的目标号段为[k*10000,(k+10)*10000-1]。In an example, the target number segment is [k, k+10], and the target number segment is extended to obtain the extended target number segment as [k*10000, (k+10)*10000-1].

发号器用于从扩展后的目标号段中选择一个号码,作为目标号码。The number sender is used to select a number from the expanded target number segment as the target number.

步骤A2、发号器通过短链接生成算法,生成短链接。In step A2, the number issuer generates a short link through a short link generation algorithm.

这里,对于发号器通过短链接生成算法,生成短链接的描述具体可参见上述S204a和S204b的描述,此处不再赘述。Here, for the description of generating the short link through the short link generation algorithm by the number issuer, please refer to the above description of S204a and S204b, which will not be repeated here.

本申请实施例中,中央号段生成器用于生成号段,代码生成器用于发放号段,使用中央号段生成器和代码生成器可以将号段生成和发放解耦,有效分担中央号段生成器的服务压力,代码生成器依赖于中央号段生成器,终端通过发号器获取字符串,这样,可以使得服务有更好的横向扩展性,当访问量较大时只需要横向扩展发号器就可以提升服务的吞吐量。通过这种设计可以支持每天上亿的访问量。In the embodiment of this application, the central number segment generator is used to generate number segments, and the code generator is used to issue number segments. Using the central number segment generator and code generator can decouple number segment generation and issuance, effectively sharing the central number segment generation The service pressure of the server, the code generator depends on the central number segment generator, and the terminal obtains the string through the number generator. In this way, the service can have better horizontal scalability. When the number of visits is large, only horizontal expansion of the number is required. The server can improve the throughput of the service. This design can support hundreds of millions of visits per day.

步骤B、存储短链接。Step B, store the short link.

这里,对于步骤B的解释,具体可以参见上述实施例中对于S207和S208的解释,此处不再赘述。Here, for the explanation of step B, refer to the explanation of S207 and S208 in the above-mentioned embodiment for details, which will not be repeated here.

由于现有技术中是先将数据存入缓存后,再将数据存入磁盘,这样,一次存储操作需要2次存储的时间开销,因此,本申请实施例中,使用消息队列将2次存储解耦,例如,在将数据存入缓存后,将数据直接放入消息队列,再由消息队列下游数据处理系统接收数据并将数据写入磁盘中,这样,可以将2次时间开销缩短为1次。Because in the prior art, the data is stored in the cache first, and then the data is stored in the disk, so that one storage operation requires two storage time overheads, therefore, in the embodiment of this application, the message queue is used to resolve the two storage operations. Coupling, for example, after storing the data in the cache, put the data directly into the message queue, and then the downstream data processing system of the message queue receives the data and writes the data to the disk. In this way, the time overhead of 2 times can be shortened to 1 time .

步骤C、对短链接进行热备份。Step C, performing hot backup on the short link.

本申请实施例中,热备份短链接的实现原理主要是通过消息队列实现的,如图4所示,在对短链接进行热备份的过程中,包括下述步骤:In the embodiment of the present application, the realization principle of the hot backup short link is mainly realized through the message queue, as shown in Figure 4, in the process of hot backup of the short link, the following steps are included:

S401、服务器将短链接发送至消息队列MQ。S401. The server sends the short link to the message queue MQ.

S402、消息队列MQ接收服务器发送的短链接,并将短链接分别存储至HBase数据库和Hive数据库。S402. The message queue MQ receives the short link sent by the server, and stores the short link in the HBase database and the Hive database respectively.

在一些实施例中,图5为发号器的实现原理示意图,如图5所示,发号器执行的功能包括:第一功能D、第二功能E以及第三功能F;其中,第一功能D为获取号码功能;第二功能E为号码加载功能;第三功能F为灾备以及故障恢复功能,下面将对这几个功能具体解释:In some embodiments, FIG. 5 is a schematic diagram of the realization principle of the signal generator. As shown in FIG. 5 , the functions performed by the signal device include: a first function D, a second function E, and a third function F; wherein, the first Function D is the function of obtaining numbers; the second function E is the function of number loading; the third function F is the function of disaster recovery and fault recovery. The following will explain these functions in detail:

如图5所示,在实现获取号码功能的过程中,包括如下步骤:As shown in Figure 5, in the process of realizing the function of obtaining the number, the following steps are included:

S501、发号器判断本地缓存的号码的个数是否大于预设阈值;S501. The number issuer judges whether the number of locally cached numbers is greater than a preset threshold;

S502、若大于预设阈值,则从本地缓存的号码中获取目标号码;S502. If it is greater than the preset threshold, obtain the target number from the locally cached numbers;

S503、若小于等于预设阈值,则提交号码加载任务至线程池。S503. If it is less than or equal to the preset threshold, submit the number loading task to the thread pool.

在提交号码加载任务至线性池后,发号器可以对号码进行异步加载。After submitting the number loading task to the linear pool, the number issuer can load the number asynchronously.

如图5所示,在实现号码加载功能的过程中,包括如下步骤:As shown in Figure 5, in the process of realizing the number loading function, the following steps are included:

S504、发号器获取目标号段中的最小值X;S504. The signal transmitter acquires the minimum value X in the target number segment;

S505、发号器对目标号段中的最小值和最大值进行扩展。S505. The signal sender expands the minimum value and maximum value in the target number segment.

在一示例中,对目标号段中的最小值和最大值进行扩展后的目标号段可以是:[X*100000,In an example, the target number segment after extending the minimum value and the maximum value in the target number segment may be: [X*100000,

(X+10)*100000];(X+10)*100000];

S506、发号器生成所有号码;S506, the number generator generates all numbers;

S507、发号器打乱所有号码顺序;S507, the number generator disrupts the sequence of all numbers;

S508、发号器将所有号码保存到本地缓存;S508. The number issuing device saves all numbers to a local cache;

S509、发号器提交灾备任务到线性池。S509. The number issuer submits the disaster recovery task to the linear pool.

在发号器将灾备任务提交到线性池后,发号器可以进行异步灾备。After the issuer submits the disaster recovery task to the linear pool, the issuer can perform asynchronous disaster recovery.

在灾备以及故障恢复过程中,包括如下步骤:In the process of disaster recovery and failure recovery, the following steps are included:

S510、备份线程从Redis中获取最新的号码值;S510, the backup thread obtains the latest number value from Redis;

S511、从灾备数据库MySql中获取最新的号码值;S511. Obtain the latest number value from the disaster recovery database MySql;

S512、判断Redis中获取的最新的号码值是否小于灾备数据库MySql中获取的最新的号码值;S512, judging whether the latest number value obtained in Redis is smaller than the latest number value obtained in the disaster recovery database MySql;

S513、若Redis中的最新的号码值大于等于灾备数据库MySql的最新的号码值,则说明Redis中的号码值没有被删除或者被篡改过;S513. If the latest number value in Redis is greater than or equal to the latest number value in the disaster recovery database MySql, it means that the number value in Redis has not been deleted or tampered with;

在Redis中的号码值没有被删除或者被篡改过的情况下,可以更新Redis中的号码值到灾备数据库MySql。In the case that the number value in Redis has not been deleted or tampered with, the number value in Redis can be updated to the disaster recovery database MySql.

S514、若Redis中的最新的号码值小于灾备数据库MySql中最新的号码值,则说明Redis中的号码值被删除或者被篡改过;S514. If the latest number value in Redis is smaller than the latest number value in the disaster recovery database MySql, it means that the number value in Redis has been deleted or tampered with;

S515、对Redis进行监控并向相关人员进行报警,并且对故障进行恢复。S515. Monitor the Redis and send an alarm to relevant personnel, and recover the fault.

在一示例中,可以通过执行回滚操作,对故障进行恢复,该回滚操作为将Redis中的最新的号码值设置为灾备数据库MySql的号码值+1000。In an example, the fault can be recovered by performing a rollback operation, the rollback operation is setting the latest number value in Redis to the number value of the disaster recovery database MySql+1000.

通过将获取号码、号码加载、灾备以及故障恢复这四个部分通过异步编程的方式实现解耦,能够实现自动进行灾备、故障检测和故障修复,发号性能低于1ms,并且由于服务器之间的号码池完全隔离,因此,本申请实施例提供的发号器具备高并发、高性能、高可靠性的优势。By decoupling the four parts of number acquisition, number loading, disaster recovery, and fault recovery through asynchronous programming, automatic disaster recovery, fault detection, and fault recovery can be realized. The number sending performance is less than 1ms, and due to the The number pools between are completely isolated. Therefore, the number issuer provided by the embodiment of the present application has the advantages of high concurrency, high performance, and high reliability.

如图6所示,中央号段生成器可生成多个号段,并将多个号段发送给发号器,发号器可以从中央号段生成器中获取号段,发号器获取号段以后会将号段数字打乱,乱序保存在本地,每次从本地存储器中按需取出可以使用的号码,号码取出后,就丢弃,不可以再次发放给第二个终端。乱序可以让终端在获取数据时感觉号段是随机产生的。例如从中央号段生成器获取号段是[0,9],那么在本地的存储可能是[7,6,0,5,2,3,4,1,8,9](随机存储,也可能是别的序列)。As shown in Figure 6, the central number segment generator can generate multiple number segments and send multiple number segments to the number issuer. The number issuer can obtain the number segment from the central number segment generator, and the number issuer can obtain the number After the segment, the digits of the number segment will be scrambled, and the sequence will be stored locally. Every time the number that can be used is taken out from the local storage as needed, after the number is taken out, it will be discarded and cannot be issued to the second terminal again. Out of order can make the terminal feel that the number segment is randomly generated when acquiring data. For example, the number segment obtained from the central number segment generator is [0, 9], then the local storage may be [7, 6, 0, 5, 2, 3, 4, 1, 8, 9] (random storage, also possibly another sequence).

下面将对短链接生成算法作详细解释。The short link generation algorithm will be explained in detail below.

发号器保证了高性能的获取唯一号码,短链接生成算法需要做的就是保证号码与短链的唯一映射。通过保证每次获取的短链具有唯一性,我们可以大量较少操作Redis的次数,大大减少因为操作Redis而带来的时间开销,从而提高短链接的生成性能。The number issuer ensures high-performance access to unique numbers, and what the short link generation algorithm needs to do is to ensure the unique mapping between the number and the short link. By ensuring the uniqueness of the short links obtained each time, we can reduce the number of operations on Redis and greatly reduce the time overhead caused by operating Redis, thereby improving the performance of short link generation.

短链接生成算法所采用的思想是将10进制数字转换成16进制的数字,使用取模映射法,生成字符串位数和取模次数相等,实现随机字符串生成长度的可控性。The idea adopted by the short link generation algorithm is to convert decimal numbers into hexadecimal numbers, and use the modulus mapping method to generate a string with the same number of digits as the number of modulus, so as to realize the controllability of the length of the random string generation.

本申请实施例中,短链接生成算法包括上述的S204a和S204b,具体解释请参见上述实施例中对于S204a和S204b的解释,此处不再赘述。In the embodiment of the present application, the short link generation algorithm includes the above-mentioned S204a and S204b. For specific explanations, please refer to the explanations of S204a and S204b in the above-mentioned embodiments, which will not be repeated here.

下面将对存储和热备份短链接进行详细解释。The storage and hot backup short links are explained in detail below.

本申请实施例中,存储和热备份短链的过程是异步解耦的,从而可以解决现有流程过长,非核心流程影响主流程性能等系统问题。In the embodiment of the present application, the processes of storing and hot backup short chains are asynchronously decoupled, so that system problems such as excessively long existing processes and non-core processes affecting the performance of the main process can be solved.

短链接生成以后将短链接和相关数据保存在分布式内存数据库Redis中,然后再将数据放入消息队列MQ等中间件中,由对应的热备份流程进行后续数据的备份工作。通过引入MQ,可以实现对短链接进行存储和热备份的异步解耦,从而可以实现短链接生成的高效性。After the short link is generated, the short link and related data are stored in the distributed memory database Redis, and then the data is put into middleware such as message queue MQ, and the subsequent data backup is performed by the corresponding hot backup process. By introducing MQ, the asynchronous decoupling of storage and hot backup of short links can be realized, so that the efficiency of short link generation can be realized.

如图7所示,对短链接进行存储和热备份主要包含两大部分:异步发送MQ消息机制和失败消息补救机制。As shown in Figure 7, the short link storage and hot backup mainly include two parts: asynchronous sending MQ message mechanism and failure message recovery mechanism.

其中,在异步发送MQ消息机制中,包括:Among them, in the asynchronous sending MQ message mechanism, including:

S701、发号器生成短链接;S701. The number generator generates a short link;

S702、通过Redis对短链接进行存储;S702. Store the short link through Redis;

S703、发号器将短链接发送至消息队列MQ;S703. The sender sends the short link to the message queue MQ;

S704、发号器判断MQ网络是否异常;S704, the signal generator judges whether the MQ network is abnormal;

S705、若异常,则将短链接发送至补发消息列表msgList;S705. If abnormal, send the short link to the reissue message list msgList;

S706、若不异常,则将短链接发送至消息队列MQ。S706. If there is no abnormality, send the short link to the message queue MQ.

在将短链接发送至消息队列MQ后,发号器将短链接分别发送至HBase数据库和Hive数据库。After sending the short link to the message queue MQ, the sender sends the short link to the HBase database and the Hive database respectively.

在失败消息补救机制中,通过补发消息线程,可以对因MQ网络异常而未发送至消息队列的短链接进行重新发送,通过备份消息线程,可以对补发消息线程中的短链接进行备份,其中,备份消息线程,包括:In the failure message recovery mechanism, the short link that has not been sent to the message queue due to MQ network abnormality can be resent by reissuing the message thread, and the short link in the reissued message thread can be backed up by backing up the message thread. Among them, the backup message thread includes:

S707、通过备份消息线程,对补发消息列表中的短链接进行备份;S707. Back up the short link in the reissued message list by backing up the message thread;

S708、判断创建时间是否超过预设时间;S708. Determine whether the creation time exceeds a preset time;

S709、若超过预设时间,则把超过预设时间的未执行的短链接重新发送到补发消息列表msgList;S709. If the preset time is exceeded, resend the unexecuted short link exceeding the preset time to the reissue message list msgList;

本申请实施例中,异步发送MQ消息机制主要是借助与MQ相关的客户端(Client)实现的,发送结果会调用回调函数:发送成功的短链接可以被异步写入HBase和Hive;发送失败的短链接可以保存到补发消息列表msgList。失败消息补救机制主要用于解决当MQ网络异常的补救,MQ网络异常会给系统带来灾难性影响,会在一段时间内导致短链服务整体不可用,所以我们在MQ网络异常的情况下采用快速失败策略。快速失败策略可以快速的给用户反馈结果,不影响核心流程。In the embodiment of this application, the asynchronous sending MQ message mechanism is mainly realized by means of the client (Client) related to MQ, and the sending result will call the callback function: the short link sent successfully can be written into HBase and Hive asynchronously; The short link can be saved to the resend message list msgList. The failure message remediation mechanism is mainly used to solve the remediation when the MQ network is abnormal. The MQ network anomaly will have a catastrophic impact on the system and will cause the overall short-chain service to be unavailable for a period of time. Therefore, we use it when the MQ network is abnormal. Fail fast strategy. The fail-fast strategy can quickly give users feedback results without affecting the core process.

补发消息列表msgList和备份消息列表backUpList是使用Redis实现的一个先进先出队列,通过LPUSH指令保存消息,通过RPOP指令获取消息,从而保证了消息执行的顺序性以及高效性,消息的执行时间复杂度为O(1)。补发消息列表msgList主要是保存哪些消息需要通过补发消息线程进行补发;备份消息列表backUpList主要是保存哪些补发消息已经被补发消息线程获取了,即对补发消息列表中的消息进行备份。The reissued message list msgList and the backup message list backUpList are a first-in-first-out queue implemented using Redis. Messages are saved through the LPUSH instruction and obtained through the RPOP instruction, thereby ensuring the order and efficiency of message execution, and the execution time of messages is complex. The degree is O(1). The reissued message list msgList mainly stores which messages need to be reissued through the reissued message thread; the backup message list backUpList mainly stores which reissued messages have been obtained by the reissued message thread, that is, the messages in the reissued message list are backup.

补发消息线程定时扫描补发消息列表msgList,对发送失败的消息进行再次发送。比如,当查询到补发消息列表msgList有消息message1,这时补发消息线程会通过Redis的BRPOPLPUSH命令把message1从补发消息列表msgList删除并原子性的保存到备份消息列表backUpList。如果补发消息 线程发送MQ成功,则再次从备份消息列表删除message1;如果补发消息线程崩溃了或者发送MQ失败,则不做处理。The resend message thread regularly scans the resend message list msgList, and resends the failed message. For example, when the reissued message list msgList is found to have message message1, the reissued message thread will delete message1 from the reissued message list msgList through the Redis BRPOPLPUSH command and atomically save it to the backup message list backUpList. If the resend message thread successfully sends MQ, delete message1 from the backup message list again; if the resend message thread crashes or fails to send MQ, it will not be processed.

备份消息线程定时扫描备份消息列表backUpList,把长时间未删除的消息重新放到补发消息列表msgList。比如上述message1在被补发消息线程获取之后崩溃了,就会导致message1没有从备份消息列表删除,这时候备份消息线程就会获取到message1,如果message1的消息创建时间大于设定的时间阈值,例如,30分钟,则备份消息线程则会通过Redis的BRPOPLPUSH命令把message1从备份消息列表backUpList删除并原子性的保存到补发消息列表msgList。The backup message thread regularly scans the backup message list backUpList, and puts the messages that have not been deleted for a long time into the reissued message list msgList. For example, if the above message1 crashes after being retrieved by the reissued message thread, message1 will not be deleted from the backup message list. At this time, the backup message thread will obtain message1. If the message creation time of message1 is greater than the set time threshold, for example , 30 minutes, the backup message thread will delete message1 from the backup message list backUpList through the Redis BRPOPLPUSH command and atomically save it to the reissue message list msgList.

本申请实施例中,通过引入发号器、优化生成算法、异步化解耦存储和热备份,可以使得性能从之前的17ms提升到3ms。In the embodiment of this application, the performance can be improved from the previous 17ms to 3ms by introducing a signal generator, optimized generation algorithm, asynchronous decoupled storage, and hot backup.

图8为本申请实施例提供的一种短链接生成装置,如图8所示,该短链接生成装置800包括:FIG. 8 is a short link generation device provided by the embodiment of the present application. As shown in FIG. 8, the short link generation device 800 includes:

获取单元801,配置为获取目标号段;所述目标号段的最小值与所述目标号段的前一个号段的最大值相同,所述目标号段的最大值与所述目标号段的后一个号段的最小值相同,所述目标号段包括第一数量的号码;The acquiring unit 801 is configured to acquire a target number segment; the minimum value of the target number segment is the same as the maximum value of the previous number segment of the target number segment, and the maximum value of the target number segment is the same as the target number segment The minimum value of the latter number segment is the same, and the target number segment includes the first number of numbers;

处理单元802,配置为对所述目标号段的最小值和最大值进行扩展,得到扩展后的目标号段,所述扩展后的目标号段包括第二数量的号码,所述第二数量大于所述第一数量;The processing unit 802 is configured to extend the minimum value and the maximum value of the target number segment to obtain an extended target number segment, and the extended target number segment includes a second number of numbers, and the second number is greater than said first quantity;

确定单元803,配置为从所述第二数量的号码中确定目标号码;A determining unit 803 configured to determine a target number from the second number of numbers;

所述确定单元803,还配置为对所述目标号码进行转换,确定短链接。The determining unit 803 is further configured to convert the target number to determine a short link.

在一些实施例中,获取单元801,还配置为判断本地缓存的号码的数量是否小于预设阈值;若所述本地缓存的号码的数量小于等于所述预设阈值,则获取目标号段。In some embodiments, the acquiring unit 801 is further configured to determine whether the number of locally cached numbers is less than a preset threshold; if the number of locally cached numbers is less than or equal to the preset threshold, acquire the target number segment.

在一些实施例中,确定单元803,还配置为若所述本地缓存的号码的数量大于所述预设阈值,则从所述本地缓存的号码中确定目标号码。In some embodiments, the determining unit 803 is further configured to determine a target number from the locally cached numbers if the number of the locally cached numbers is greater than the preset threshold.

在一些实施例中,确定单元803,还配置为对所述目标号码进行取模,得到取模结果,所述取模结果包括:至少一个取模参数;确定所述至少一个取模参数中的每一个所述取模参数对应的字符;至少一个所述字符组成所述短链接。In some embodiments, the determining unit 803 is further configured to take a modulo on the target number to obtain a modulo result, the modulo result including: at least one modulo parameter; determining the at least one modulo parameter Each of the characters corresponding to the modulo parameter; at least one of the characters constitutes the short link.

在一些实施例中,短链接生成装置还包括:排序单元;获取单元801,还配置为获取排序策略;排序单元,配置为基于所述排序策略将所述目标号段所包括的第一数量的号码进行排序。In some embodiments, the device for generating short links further includes: a sorting unit; the acquiring unit 801 is also configured to acquire a sorting strategy; and the sorting unit is configured to sort the first number of the target number segments included in the target number segment based on the sorting strategy number to sort.

在一些实施例中,短链接生成装置还包括:存储单元;所述存储单元配置为对所述短链接进行一次存储,存储至第一存储区域;所述第一次存储区域用于实现对所述短链接的高速存取;所述存储单元还配置为对所述短链接进行二次存储,存储至第二存储区域;所述第二次存储区域用于实现对所述短链接的备份。In some embodiments, the device for generating a short link further includes: a storage unit; the storage unit is configured to store the short link once, and store it in the first storage area; the first storage area is used to realize the storage of the short link The high-speed access of the short link; the storage unit is also configured to store the short link twice in a second storage area; the second storage area is used to realize the backup of the short link.

在一些实施例中,短链接生成装置还包括:发送单元;所述发送单元,配置为将所述短链接发送至消息队列;存储单元,还配置为消费所述消息队列中的所述短链接,分别将所述短链接存储至第一数据库和第二数据库,所述第一数据库与所述第二数据库不同。In some embodiments, the short link generation device further includes: a sending unit; the sending unit is configured to send the short link to a message queue; a storage unit is also configured to consume the short link in the message queue , respectively storing the short link in a first database and a second database, where the first database is different from the second database.

在一些实施例中,发送单元,还配置为判断所述消息队列的网络是否异常;若所述消息队列的 网络异常,则通过补发消息线程将所述短链接发送至补发消息列表,并将所述补发消息列表中的短链接重新发送至所述消息队列。In some embodiments, the sending unit is further configured to determine whether the network of the message queue is abnormal; if the network of the message queue is abnormal, send the short link to the reissue message list through the reissue message thread, and Resend the short links in the resent message list to the message queue.

在一些实施例中,处理单元还配置为通过备份消息线程,将所述补发消息列表中的短链接备份至备份消息列表;判断所述补发消息列表中的短链接是否重新发送至所述消息队列;若所述补发消息列表中的短链接重新发送至所述消息队列,则将备份消息列表中的与所述补发消息列表中的重新发送至消息队列的短链接删除;若所述补发消息列表中的短链接没有重新发送至所述消息队列,则对备份消息列表中的与所述补发消息列表中对应的短链接进行保留,当保留时长大于预设时长时,则将所述备份消息列表中的短链接重新发送至所述补发消息列表。In some embodiments, the processing unit is further configured to back up the short link in the reissued message list to the backup message list through the backup message thread; determine whether the short link in the reissued message list is resent to the Message queue; if the short link in the reissued message list is resent to the message queue, delete the short link in the backup message list and the resent message queue in the reissued message list; if the If the short link in the reissued message list is not resent to the message queue, then the short link corresponding to the reissued message list in the backup message list is reserved, and when the retention time is longer than the preset time length, then Resend the short link in the backup message list to the reissue message list.

本申请实施例还提供一种电子设备,包括存储器和处理器,所述存储器存储有可在处理器上运行的计算机程序,所述处理器执行所述程序时实现上述实施例中提供的短链接生成方法。其中,该电子设备可为客户端,也可为服务端。The embodiment of the present application also provides an electronic device, including a memory and a processor, the memory stores a computer program that can run on the processor, and the processor implements the short link provided in the above embodiment when executing the program generate method. Wherein, the electronic device may be a client or a server.

本申请实施例还提供一种存储介质,也就是计算机可读存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现上述实施例中提供的短链接生成方法。The embodiment of the present application also provides a storage medium, that is, a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the method for generating a short link provided in the above-mentioned embodiment is implemented.

这里需要指出的是:以上存储介质和设备实施例的描述,与上述方法实施例的描述是类似的,具有同方法实施例相似的有益效果。对于本申请存储介质和设备实施例中未披露的技术细节,请参照本申请方法实施例的描述而理解。It should be pointed out here that: the descriptions of the above storage medium and device embodiments are similar to the descriptions of the above method embodiments, and have similar beneficial effects to those of the method embodiments. For technical details not disclosed in the storage medium and device embodiments of the present application, please refer to the description of the method embodiments of the present application for understanding.

需要说明的是,图9为本申请实施例电子设备的一种硬件实体示意图,如图9所示,所述电子设备900包括:一个处理器901、至少一个通信总线902、至少一个外部通信接口904和存储器905。其中,通信总线902配置为实现这些组件之间的连接通信。在一示例中,电子设备900还包括:用户接口903、其中,用户接口903可以包括显示屏,外部通信接口904可以包括标准的有线接口和无线接口。It should be noted that FIG. 9 is a schematic diagram of a hardware entity of an electronic device according to an embodiment of the present application. As shown in FIG. 9 , the electronic device 900 includes: a processor 901, at least one communication bus 902, and at least one external communication interface 904 and memory 905. Wherein, the communication bus 902 is configured to realize connection and communication among these components. In an example, the electronic device 900 further includes: a user interface 903, wherein the user interface 903 may include a display screen, and the external communication interface 904 may include a standard wired interface and a wireless interface.

存储器905配置为存储由处理器901可执行的指令和应用,还可以缓存待处理器901以及电子设备中各模块待处理或已经处理的数据(例如,图像数据、音频数据、语音通信数据和视频通信数据),可以通过闪存(FLASH)或随机访问存储器(Random Access Memory,RAM)实现。The memory 905 is configured to store instructions and applications executable by the processor 901, and can also cache data to be processed or processed by the processor 901 and various modules in the electronic device (for example, image data, audio data, voice communication data and video data) Communication data), which can be realized by flash memory (FLASH) or random access memory (Random Access Memory, RAM).

应理解,说明书通篇中提到的“一个实施例”或“一实施例”意味着与实施例有关的特定特征、结构或特性包括在本申请的至少一个实施例中。因此,在整个说明书各处出现的“在一个实施例中”或“在一些实施例中”未必一定指相同的实施例。此外,这些特定的特征、结构或特性可以任意适合的方式结合在一个或多个实施例中。应理解,在本申请的各种实施例中,上述各过程的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。It should be understood that reference throughout the specification to "one embodiment" or "an embodiment" means that a particular feature, structure, or characteristic related to the embodiment is included in at least one embodiment of the present application. Thus, appearances of "in one embodiment" or "in some embodiments" throughout this specification are not necessarily referring to the same embodiments. Furthermore, the particular features, structures or characteristics may be combined in any suitable manner in one or more embodiments. It should be understood that, in various embodiments of the present application, the sequence numbers of the above-mentioned processes do not mean the order of execution, and the execution order of the processes should be determined by their functions and internal logic, and should not be used in the embodiments of the present application. The implementation process constitutes any limitation. The serial numbers of the above embodiments of the present application are for description only, and do not represent the advantages and disadvantages of the embodiments.

需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者装置不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者装置所固有的要素。在没有更多限 制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者装置中还存在另外的相同要素。It should be noted that, in this document, the term "comprising", "comprising" or any other variation thereof is intended to cover a non-exclusive inclusion such that a process, method, article or apparatus comprising a set of elements includes not only those elements, It also includes other elements not expressly listed, or elements inherent in the process, method, article, or device. Without further limitations, an element defined by the phrase "comprising a..." does not preclude the presence of additional identical elements in the process, method, article, or apparatus comprising that element.

在本申请所提供的几个实施例中,应该理解到,所揭露的设备和方法,可以通过其它的方式实现。以上所描述的设备实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,如:多个单元或组件可以结合,或可以集成到另一个系统,或一些特征可以忽略,或不执行。另外,所显示或讨论的各组成部分相互之间的耦合、或直接耦合、或通信连接可以是通过一些接口,设备或单元的间接耦合或通信连接,可以是电性的、机械的或其它形式的。In the several embodiments provided in this application, it should be understood that the disclosed devices and methods may be implemented in other ways. The device embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods, such as: multiple units or components can be combined, or May be integrated into another system, or some features may be ignored, or not implemented. In addition, the coupling, or direct coupling, or communication connection between the components shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be electrical, mechanical or other forms of.

上述作为分离部件说明的单元可以是、或也可以不是物理上分开的,作为单元显示的部件可以是、或也可以不是物理单元;既可以位于一个地方,也可以分布到多个网络单元上;可以根据实际的需要选择其中的部分或全部单元来实现本实施例方案的目的。The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed to multiple network units; Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

另外,在本申请各实施例中的各功能单元可以全部集成在一个处理单元中,也可以是各单元分别单独作为一个单元,也可以两个或两个以上单元集成在一个单元中;上述集成的单元既可以采用硬件的形式实现,也可以采用硬件加软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present application can be integrated into one processing unit, or each unit can be used as a single unit, or two or more units can be integrated into one unit; the above-mentioned integration The unit can be realized in the form of hardware or in the form of hardware plus software functional unit.

本领域普通技术人员可以理解:实现上述方法实施例的全部或部分步骤可以通过程序指令相关的硬件来完成,前述的程序可以存储于计算机可读取存储介质中,该程序在执行时,执行包括上述方法实施例的步骤;而前述的存储介质包括:移动存储设备、只读存储器(Read Only Memory,ROM)、磁碟或者光盘等各种可以存储程序代码的介质。Those of ordinary skill in the art can understand that all or part of the steps to realize the above method embodiments can be completed by hardware related to program instructions, and the aforementioned programs can be stored in computer-readable storage media. When the program is executed, the execution includes The steps of the foregoing method embodiments; and the foregoing storage media include: removable storage devices, read-only memory (Read Only Memory, ROM), magnetic disks or optical disks and other media that can store program codes.

或者,本申请上述集成的单元如果以软件功能模块的形式实现并作为独立的产品销售或使用时,也可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请实施例的技术方案本质上或者说对相关技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机、服务器、或者网络设备等)执行本申请各个实施例所述方法的全部或部分。而前述的存储介质包括:移动存储设备、ROM、磁碟或者光盘等各种可以存储程序代码的介质。Alternatively, if the above-mentioned integrated units of the present application are realized in the form of software function modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the essence of the technical solutions of the embodiments of the present application or the part that contributes to related technologies can be embodied in the form of software products. The computer software products are stored in a storage medium and include several instructions to make A computer device (which may be a personal computer, a server, or a network device, etc.) executes all or part of the methods described in the various embodiments of the present application. The aforementioned storage medium includes various media capable of storing program codes such as removable storage devices, ROMs, magnetic disks or optical disks.

以上所述,仅为本申请的实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。The above is only the embodiment of the present application, but the scope of protection of the present application is not limited thereto. Anyone familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, and should covered within the scope of protection of this application. Therefore, the protection scope of the present application should be determined by the protection scope of the claims.

以上所述,仅为本发明的较佳实施例而已,并非用于限定本发明的保护范围,凡在本发明的精神和原则之内所作的任何修改、等同替换和改进等,均应包含在本发明的保护范围之内。The above description is only a preferred embodiment of the present invention, and is not used to limit the protection scope of the present invention. Any modifications, equivalent replacements and improvements made within the spirit and principles of the present invention shall be included in the within the protection scope of the present invention.

Claims (20)

一种短链接生成方法,所述方法包括:A method for generating short links, the method comprising: 获取目标号段;所述目标号段的最小值与所述目标号段的前一个号段的最大值相同,所述目标号段的最大值与所述目标号段的后一个号段的最小值相同,所述目标号段包括第一数量的号码;Obtain the target number segment; the minimum value of the target number segment is the same as the maximum value of the previous number segment of the target number segment, and the maximum value of the target number segment is the minimum value of the subsequent number segment of the target number segment The values are the same, and the target number segment includes the first number of numbers; 对所述目标号段的最小值和最大值进行扩展,得到扩展后的目标号段,所述扩展后的目标号段包括第二数量的号码,所述第二数量大于所述第一数量;Extending the minimum value and the maximum value of the target number segment to obtain an extended target number segment, the expanded target number segment includes a second number of numbers, and the second number is greater than the first number; 从所述第二数量的号码中确定目标号码;determining a target number from said second number of numbers; 对所述目标号码进行转换,确定短链接。The target number is converted to determine the short link. 根据权利要求1所述的方法,其中,所述获取目标号段,包括:The method according to claim 1, wherein said obtaining the target number segment comprises: 判断本地缓存的号码的数量是否小于预设阈值;Judging whether the number of locally cached numbers is less than a preset threshold; 若所述本地缓存的号码的数量小于等于所述预设阈值,则获取目标号段。If the number of numbers cached locally is less than or equal to the preset threshold, the target number segment is acquired. 根据权利要求2所述的方法,其中,所述方法还包括:The method according to claim 2, wherein the method further comprises: 若所述本地缓存的号码的数量大于所述预设阈值,则从所述本地缓存的号码中确定目标号码。If the number of the locally cached numbers is greater than the preset threshold, then determine a target number from the locally cached numbers. 根据权利要求1所述的方法,其中,所述对所述目标号码进行转换,确定短链接,包括:The method according to claim 1, wherein said converting said target number and determining a short link comprises: 对所述目标号码进行取模,得到取模结果,所述取模结果包括:至少一个取模参数;Carrying out modulo taking on the target number to obtain a modulo taking result, the modulo taking result including: at least one modulo taking parameter; 确定所述至少一个取模参数中的每一个所述取模参数对应的字符;至少一个所述字符组成所述短链接。Determining characters corresponding to each of the modulo parameters in the at least one modulo parameter; at least one of the characters forms the short link. 根据权利要求1所述的方法,其中,所述获取目标号段后,所述方法还包括:The method according to claim 1, wherein, after the acquisition of the target number segment, the method further comprises: 获取排序策略;Get sorting strategy; 基于所述排序策略将所述目标号段所包括的第一数量的号码进行排序。sorting the first number of numbers included in the target number segment based on the sorting strategy. 根据权利要求1所述的方法,其中,所述对所述目标号码进行转换,确定短链接后,所述方法还包括:The method according to claim 1, wherein, after converting the target number and determining the short link, the method further includes: 对所述短链接进行一次存储,存储至第一存储区域;所述第一次存储区域用于实现对所述短链接的高速存取;Store the short link once, and store it in the first storage area; the first storage area is used to realize high-speed access to the short link; 对所述短链接进行二次存储,存储至第二存储区域;所述第二次存储区域用于实现对所述短链接的备份。The short link is stored secondary to a second storage area; the second storage area is used to realize the backup of the short link. 根据权利要求6所述的方法,其中,所述方法还包括:The method according to claim 6, wherein the method further comprises: 将所述短链接发送至消息队列;Send the short link to the message queue; 所述对所述短链接进行一次存储,存储至第二存储区域,包括:The said short link is stored once and stored in the second storage area, including: 消费所述消息队列中的所述短链接,分别将所述短链接存储至第一数据库和第二数据库,所述第一数据库与所述第二数据库不同。The short link in the message queue is consumed, and the short link is respectively stored in a first database and a second database, and the first database is different from the second database. 根据权利要求7所述的方法,其中,所述将所述短链接发送至消息队列,包括:The method according to claim 7, wherein said sending said short link to a message queue comprises: 判断所述消息队列的网络是否异常;judging whether the network of the message queue is abnormal; 若所述消息队列的网络异常,则通过补发消息线程将所述短链接发送至补发消息列表,并将所述补发消息列表中的短链接重新发送至所述消息队列。If the network of the message queue is abnormal, the short link is sent to the reissue message list through the reissue message thread, and the short link in the reissue message list is resent to the message queue. 根据权利要求8所述的方法,其中,所述通过补发消息线程将所述短链接发送至补发消息列表之后,所述方法还包括:The method according to claim 8, wherein, after sending the short link to the reissue message list through the reissue message thread, the method further comprises: 通过备份消息线程,将所述补发消息列表中的短链接备份至备份消息列表;Back up the short links in the reissued message list to the backup message list through the backup message thread; 判断所述补发消息列表中的短链接是否重新发送至所述消息队列;Judging whether the short link in the reissued message list is resent to the message queue; 若所述补发消息列表中的短链接重新发送至所述消息队列,则将备份消息列表中的与所述补发消息列表中的重新发送至消息队列的短链接删除;If the short link in the reissue message list is resent to the message queue, delete the short link in the backup message list and the resend message queue in the reissue message list; 若所述补发消息列表中的短链接没有重新发送至所述消息队列,则对备份消息列表中的与所述补发消息列表中对应的短链接进行保留,当保留时长大于预设时长时,则将所述备份消息列表中的短链接重新发送至所述补发消息列表。If the short link in the reissued message list is not resent to the message queue, then reserve the corresponding short link in the backup message list and the reissued message list, when the retention time is longer than the preset time length , then resend the short link in the backup message list to the reissue message list. 一种短链接生成装置,所述装置包括:A short link generation device, said device comprising: 获取单元,配置为获取目标号段;所述目标号段的最小值与所述目标号段的前一个号段的最大值相同,所述目标号段的最大值与所述目标号段的后一个号段的最小值相同,所述目标号段包括第一数量的号码;An acquisition unit configured to acquire a target number segment; the minimum value of the target number segment is the same as the maximum value of the previous number segment of the target number segment, and the maximum value of the target number segment is the same as the maximum value of the target number segment The minimum value of a number segment is the same, and the target number segment includes the first number of numbers; 处理单元,配置为对所述目标号段的最小值和最大值进行扩展,得到扩展后的目标号段,所述扩展后的目标号段包括第二数量的号码,所述第二数量大于所述第一数量;The processing unit is configured to extend the minimum value and the maximum value of the target number segment to obtain an extended target number segment, and the extended target number segment includes a second number of numbers, and the second number is greater than the specified number the first quantity; 确定单元,配置为从所述第二数量的号码中确定目标号码;a determination unit configured to determine a target number from said second number of numbers; 所述确定单元,还配置为对所述目标号码进行转换,确定短链接。The determining unit is further configured to convert the target number to determine a short link. 根据权利要求10所述的短链接生成装置,其中,所述获取单元,还配置为:The short link generating device according to claim 10, wherein the acquiring unit is further configured to: 判断本地缓存的号码的数量是否小于预设阈值;Judging whether the number of locally cached numbers is less than a preset threshold; 若所述本地缓存的号码的数量小于等于所述预设阈值,则获取目标号段。If the number of numbers cached locally is less than or equal to the preset threshold, the target number segment is acquired. 根据权利要求11所述的短链接生成装置,其中,所述确定单元,还配置为:The device for generating short links according to claim 11, wherein the determining unit is further configured to: 若所述本地缓存的号码的数量大于所述预设阈值,则从所述本地缓存的号码中确定目标号码。If the number of the locally cached numbers is greater than the preset threshold, then determine a target number from the locally cached numbers. 根据权利要求10所述的短链接生成装置,其中,所述确定单元,还配置为:The device for generating short links according to claim 10, wherein the determining unit is further configured to: 对所述目标号码进行取模,得到取模结果,所述取模结果包括:至少一个取模参数;Carrying out modulo taking on the target number to obtain a modulo taking result, the modulo taking result including: at least one modulo taking parameter; 确定所述至少一个取模参数中的每一个所述取模参数对应的字符;至少一个所述字符组成所述短链接。Determining characters corresponding to each of the modulo parameters in the at least one modulo parameter; at least one of the characters forms the short link. 根据权利要求10所述的短链接生成装置,其中,所述获取单元还配置为:获取排序策略;The device for generating short links according to claim 10, wherein the obtaining unit is further configured to: obtain a sorting strategy; 所述短链接生成装置还包括:排序单元,配置为基于所述排序策略将所述目标号段所包括 的第一数量的号码进行排序。The short link generation device further includes: a sorting unit configured to sort the first number of numbers included in the target number segment based on the sorting strategy. 根据权利要求10所述的短链接生成装置,其中,所述短链接生成装置还包括:存储单元,配置为:The short link generating device according to claim 10, wherein the short link generating device further comprises: a storage unit configured to: 对所述短链接进行一次存储,存储至第一存储区域;所述第一次存储区域用于实现对所述短链接的高速存取;Store the short link once, and store it in the first storage area; the first storage area is used to realize high-speed access to the short link; 对所述短链接进行二次存储,存储至第二存储区域;所述第二次存储区域用于实现对所述短链接的备份。The short link is stored secondary to a second storage area; the second storage area is used to realize the backup of the short link. 根据权利要求15所述的短链接生成装置,其中,所述短链接生成装置还包括:发送单元,配置为:The short link generating device according to claim 15, wherein the short link generating device further comprises: a sending unit configured to: 将所述短链接发送至消息队列;Send the short link to the message queue; 所述存储单元,还配置为:The storage unit is also configured as: 消费所述消息队列中的所述短链接,分别将所述短链接存储至第一数据库和第二数据库,所述第一数据库与所述第二数据库不同。The short link in the message queue is consumed, and the short link is respectively stored in a first database and a second database, and the first database is different from the second database. 根据权利要求16所述的短链接生成装置,其中,所述发送单元,还配置为:The short link generation device according to claim 16, wherein the sending unit is further configured to: 判断所述消息队列的网络是否异常;judging whether the network of the message queue is abnormal; 若所述消息队列的网络异常,则通过补发消息线程将所述短链接发送至补发消息列表,并将所述补发消息列表中的短链接重新发送至所述消息队列。If the network of the message queue is abnormal, the short link is sent to the reissue message list through the reissue message thread, and the short link in the reissue message list is resent to the message queue. 根据权利要求17所述的短链接生成装置,其中,所述处理单元,还配置为:The short link generation device according to claim 17, wherein the processing unit is further configured to: 通过备份消息线程,将所述补发消息列表中的短链接备份至备份消息列表;Back up the short links in the reissued message list to the backup message list through the backup message thread; 判断所述补发消息列表中的短链接是否重新发送至所述消息队列;Judging whether the short link in the reissued message list is resent to the message queue; 若所述补发消息列表中的短链接重新发送至所述消息队列,则将备份消息列表中的与所述补发消息列表中的重新发送至消息队列的短链接删除;If the short link in the reissue message list is resent to the message queue, delete the short link in the backup message list and the resend message queue in the reissue message list; 若所述补发消息列表中的短链接没有重新发送至所述消息队列,则对备份消息列表中的与所述补发消息列表中对应的短链接进行保留,当保留时长大于预设时长时,则将所述备份消息列表中的短链接重新发送至所述补发消息列表。If the short link in the reissued message list is not resent to the message queue, then reserve the corresponding short link in the backup message list and the reissued message list, when the retention time is longer than the preset time length , then resend the short link in the backup message list to the reissue message list. 一种电子设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述计算机程序时,实现权利要求1至9任一项所述的短链接生成方法。An electronic device, comprising a memory, a processor, and a computer program stored on the memory and operable on the processor, when the processor executes the computer program, the short-term device described in any one of claims 1 to 9 is realized Link generation method. 一种存储介质,存储有计算机程序,所述计算机程序被处理器执行时,实现权利要求1至9任一项所述的短链接生成方法。A storage medium storing a computer program, when the computer program is executed by a processor, the method for generating a short link according to any one of claims 1 to 9 is realized.
PCT/CN2022/093562 2021-05-19 2022-05-18 Short link generation method and apparatus, device, and storage medium Ceased WO2022242678A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110548216.1A CN113378083B (en) 2021-05-19 2021-05-19 A short link generation method, device, equipment and storage medium
CN202110548216.1 2021-05-19

Publications (1)

Publication Number Publication Date
WO2022242678A1 true WO2022242678A1 (en) 2022-11-24

Family

ID=77571384

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/093562 Ceased WO2022242678A1 (en) 2021-05-19 2022-05-18 Short link generation method and apparatus, device, and storage medium

Country Status (2)

Country Link
CN (1) CN113378083B (en)
WO (1) WO2022242678A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116501997A (en) * 2023-06-28 2023-07-28 太平金融科技服务(上海)有限公司深圳分公司 Short link generation method, device, electronic equipment and storage medium
CN120358524A (en) * 2025-06-20 2025-07-22 上海大汉三通通信股份有限公司 Short-chain management method, device, equipment and medium

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113378083B (en) * 2021-05-19 2023-09-29 北京沃东天骏信息技术有限公司 A short link generation method, device, equipment and storage medium
CN115525846A (en) * 2022-09-21 2022-12-27 北京沃东天骏信息技术有限公司 Page query method and device
CN117216427A (en) * 2023-09-27 2023-12-12 同盾网络科技有限公司 Loading of short links, methods, devices, equipment and media for obtaining short links
CN120068801A (en) * 2023-11-30 2025-05-30 北京有竹居网络技术有限公司 Number generation method and device, electronic equipment and readable medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180307773A1 (en) * 2015-12-30 2018-10-25 Alibaba Group Holding Limited Short link processing to improve service efficiency
CN110851748A (en) * 2019-10-14 2020-02-28 平安科技(深圳)有限公司 Short link generation method, server, storage medium and computer equipment
CN111026985A (en) * 2019-12-02 2020-04-17 北京齐尔布莱特科技有限公司 Method, device and server for generating short link
CN112784183A (en) * 2019-11-07 2021-05-11 北京京东尚科信息技术有限公司 Short chain joint generation method and device
CN113378083A (en) * 2021-05-19 2021-09-10 北京沃东天骏信息技术有限公司 Short link generation method, device, equipment and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180307773A1 (en) * 2015-12-30 2018-10-25 Alibaba Group Holding Limited Short link processing to improve service efficiency
CN110851748A (en) * 2019-10-14 2020-02-28 平安科技(深圳)有限公司 Short link generation method, server, storage medium and computer equipment
CN112784183A (en) * 2019-11-07 2021-05-11 北京京东尚科信息技术有限公司 Short chain joint generation method and device
CN111026985A (en) * 2019-12-02 2020-04-17 北京齐尔布莱特科技有限公司 Method, device and server for generating short link
CN113378083A (en) * 2021-05-19 2021-09-10 北京沃东天骏信息技术有限公司 Short link generation method, device, equipment and storage medium

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116501997A (en) * 2023-06-28 2023-07-28 太平金融科技服务(上海)有限公司深圳分公司 Short link generation method, device, electronic equipment and storage medium
CN116501997B (en) * 2023-06-28 2023-09-26 太平金融科技服务(上海)有限公司深圳分公司 Short link generation method, device, electronic equipment and storage medium
CN120358524A (en) * 2025-06-20 2025-07-22 上海大汉三通通信股份有限公司 Short-chain management method, device, equipment and medium

Also Published As

Publication number Publication date
CN113378083B (en) 2023-09-29
CN113378083A (en) 2021-09-10

Similar Documents

Publication Publication Date Title
WO2022242678A1 (en) Short link generation method and apparatus, device, and storage medium
JP5631373B2 (en) Probabilistic techniques for matching cache entries
US7647595B2 (en) Efficient event notification in clustered computing environments
US8935560B2 (en) System and method of file locking in a network file system federated namespace
US7769731B2 (en) Using file backup software to generate an alert when a file modification policy is violated
US7680998B1 (en) Journaled data backup during server quiescence or unavailability
US8843581B2 (en) Live object pattern for use with a distributed cache
EP3227801B1 (en) Message broker system with parallel persistence
CN111274310A (en) A distributed data cache method and system
WO2017050014A1 (en) Data storage processing method and device
JP2009181590A (en) Selective data backup
CN111209120A (en) Microservice data synchronization method, device and computer-readable storage medium
CN110121874B (en) A memory data replacement method, server node and data storage system
US10169441B2 (en) Synchronous data replication in a content management system
CN107370797B (en) A method and device for strongly ordered queue operation based on HBase
CN106991118A (en) Entangled based on CEPH and delete fault-tolerant reading document method and device
US10938633B2 (en) Facilitating resilient and fault tolerant asynchronous messaging
US9189303B2 (en) Shadow queues for recovery of messages
CN115190125B (en) Monitoring method and device for cache cluster
CN116662035A (en) Method and device for processing transaction message of message queue
CN109445966B (en) Event processing method, device, medium and computing equipment
CN120596435A (en) Metadata writing and reading method and device
CN116909752B (en) Page mirror image storage method, device, equipment and storage medium
CN113742355A (en) Method, device, equipment and computer readable medium for updating inventory
CN110647298B (en) Data storage control method and device

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22803998

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 250324)

122 Ep: pct application non-entry in european phase

Ref document number: 22803998

Country of ref document: EP

Kind code of ref document: A1