WO2021073156A1 - 短链接的生成方法、服务器、存储介质及计算机设备 - Google Patents

短链接的生成方法、服务器、存储介质及计算机设备 Download PDF

Info

Publication number
WO2021073156A1
WO2021073156A1 PCT/CN2020/099251 CN2020099251W WO2021073156A1 WO 2021073156 A1 WO2021073156 A1 WO 2021073156A1 CN 2020099251 W CN2020099251 W CN 2020099251W WO 2021073156 A1 WO2021073156 A1 WO 2021073156A1
Authority
WO
WIPO (PCT)
Prior art keywords
identification
identification code
short link
identifier
link
Prior art date
Application number
PCT/CN2020/099251
Other languages
English (en)
French (fr)
Inventor
黄士保
Original Assignee
平安科技(深圳)有限公司
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 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2021073156A1 publication Critical patent/WO2021073156A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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

Definitions

  • This application relates to the field of base frame operation and maintenance, and in particular to a method for generating short links, a server, a storage medium, and a computer device.
  • Short link refers to the long Uniform Resource Locator (Uniform Resource Locator (URL) URL is converted into a short URL string through program calculations, etc., so as to save the number of characters.
  • the inventor realizes that the existing short link generation method takes the original long link as input, and generates a short link corresponding to the original long link through a hash algorithm. When the user holds the short link for analysis, the short link will be retrieved according to the link storage unit, and the original URL link will be returned for address redirection.
  • the inventor found in his research that although the short link corresponding to the original long link can be generated through the existing technology, the short link is automatically generated through the hash algorithm, and is limited by the maximum 16 digits of the hash algorithm. Corresponding to different long links to generate the same short link, resulting in short link conflicts, so that visitors access to the short link access errors.
  • the embodiments of the present application provide a short link generation method, server, storage medium, and computer equipment, which are used to solve the problem of conflicts in generated short links in the prior art.
  • an embodiment of the present application provides a method for generating a short link, the method is applied to a server, and the method includes: receiving a short link acquisition request sent by a terminal device, where the short link acquisition request includes a long link;
  • the first identification code is generated according to the current time, the number of short link acquisition requests received in the current time unit, and the identification number of the server, where the first identification code is composed of numeric characters;
  • the identification code is used as a decimal value, and the first identification code is converted from a decimal value to a sixty binary value to obtain a second identification code; a short is generated according to the second identification code and the domain name in the long link Link, and return the short link to the terminal device.
  • an embodiment of the present application provides a short link generation server, including: a receiving module configured to receive a short link acquisition request sent by a terminal device, the short link acquisition request including a long link; and a first identification code generation module , For generating a first identification code according to the current time, the number of short link acquisition requests received in the current time unit, and the identification number of the server, where the first identification code is composed of numeric characters; and second The identification code generation module is configured to use the first identification code as a decimal value, and convert the first identification code from a decimal value to a sixty binary value to obtain a second identification code; and, short link generation The module is configured to generate a short link according to the second identification code and the domain name in the long link, and return the short link to the terminal device.
  • an embodiment of the present application provides a storage medium, the storage medium includes a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute the above method, for example, the following steps are performed:
  • a short link acquisition request sent by a terminal device where the short link acquisition request includes a long link;
  • the first identification code is generated according to the current time, the number of short link acquisition requests received in the current time unit, and the identification number of the server , Wherein the first identification code is composed of numeric characters; using the first identification code as a decimal value, the first identification code is converted from a decimal value to a sixty binary value to obtain a second identification code Code; generate a short link according to the second identification code and the domain name in the long link, and return the short link to the terminal device.
  • an embodiment of the present application provides a computer device, including a memory and a processor, the memory is used to store information including program instructions, the processor is used to control the execution of the program instructions, and the program instructions are processed.
  • the steps of the above method are implemented, for example, the following steps are implemented: receiving a short link acquisition request sent by a terminal device, the short link acquisition request including a long link; according to the current time, the received in the current time unit
  • the number of short link acquisition requests and the identification number of the server generate a first identification code, where the first identification code is composed of numeric characters; the first identification code is taken as a decimal value, and the first identification code is Perform a conversion process from a decimal value to a sixty binary value to obtain a second identification code; generate a short link according to the second identification code and the domain name in the long link, and return the short link to the terminal equipment.
  • the embodiments of the present application can ensure that each generated first identification code has unique identification, and further the short links generated for each long link are unique, thus avoiding the conflict of short links.
  • FIG. 1 is a flowchart of a method for generating a short link provided by an embodiment of the application.
  • Fig. 2 is a schematic block diagram of a short link generation server provided by an embodiment of the application.
  • Fig. 3 is a schematic block diagram of a computer device provided by an embodiment of the application.
  • the technical solution of the present application can be applied to the field of artificial intelligence or big data technology, for example, it can be realized through a data platform.
  • an embodiment of the application provides a method for generating a short link, which is applied to a server.
  • the server is a server in a distributed server cluster.
  • the short link provided in the embodiment of the application is The generation method includes the following steps.
  • Step S01 Receive a short link acquisition request sent by a terminal device, where the short link acquisition request includes a long link.
  • Step S02 Generate a first identification code according to the current time, the number of short link acquisition requests received in the current time unit, and the identification number of the server, where the first identification code is composed of numeric characters.
  • Step S03 The first identification code is taken as a decimal value, and the first identification code is converted from a decimal value to a sixty binary value to obtain a second identification code.
  • Step S04 Generate a short link according to the second identification code and the domain name in the long link, and return the short link to the terminal device.
  • the first identification code is generated according to the current time, the number of short link acquisition requests received in the current time unit, and the identification number of the server, and then the first identification code is converted to sixty-two in decimal. Base conversion to obtain the second identification code, and then generate the short link. Because the first identification code is generated according to the current time, the number of short link acquisition requests received in the current time unit and the identification number of the server, based on the variability of time In this way, it can be ensured that each generated first identification code has unique identification, and the short links generated for each long link are unique, thus avoiding the conflict of short links.
  • step S01 receive a short link acquisition request sent by a terminal device, where the short link acquisition request includes a long link.
  • the terminal device may be a system-end device, a terminal device of an ordinary user, or a partner device.
  • the terminal device may include various smart phones, tablet computers, personal computers (Personal Computer, PC), and so on.
  • the server receives the short link acquisition request sent by the terminal device, and the server may be any server in the distributed server cluster.
  • the short link acquisition request may also be user information corresponding to the terminal device.
  • the user information may be user-defined description information, such as the type identification of the user, the location identification of the user, or other information.
  • receiving the short link acquisition request from the requesting party may include the following steps.
  • Step S011 Receive a short link acquisition request from the requesting party, where the short link acquisition request includes a long link.
  • Step S012 Extract the domain name of the long link, and judge whether the domain name exists in the preset domain name blacklist.
  • Step S013 If not, generate a first identification code according to the current time, the number of short link acquisition requests received in the current time unit, and the identification number of the server.
  • domain names that are not allowed to be accessed by the server are recorded in the domain name blacklist. If the domain name corresponding to the long link carried in the short link acquisition request received by the server exists in the domain name blacklist, the server returns an error message or Information that cannot be accessed.
  • the security check of the long link to be converted can be performed.
  • the domain name of the long link carried in the short link acquisition request does not meet the requirements, the conversion is not allowed, and this can be increased. Apply for the security of the short link generation method provided.
  • step S02 generate a first identification code according to the current time, the number of short link acquisition requests received in the current time unit, and the identification number of the server, where the first identification code is composed of numeric characters.
  • generating the first identification code according to the current time, the number of short link acquisition requests received in the current time unit, and the identification number of the server specifically includes the following steps.
  • Step S021 Determine the first identifier, the second identifier, and the third identifier, where the first identifier is the number of time units that differ between the current time unit and the preset start time unit, and the second identifier is received within the current time unit The number of short link acquisition requests is determined, and the third identifier is the identification number of the server, where the identification number of the server is composed of numeric characters.
  • the time unit can be milliseconds, seconds, minutes, hours, etc., depending on requirements.
  • the time unit is milliseconds. For example, if the current time differs from the preset start time by 1613024787541 milliseconds, the first One identification is: 1613024787541.
  • the current time can be the local standard time.
  • Beijing time is: January 1, 2009, 0: 0: 0: 0, 0 ms
  • the start time can be preset, for example: January 1, 2000, 0: 0: 0: 0: 0 millisecond.
  • the second identifier is determined by the number of short link acquisition requests received in the current time unit. For example, if the server receives 8 short link acquisition requests in the current millisecond, the second identifier is: 8.
  • the third identification is the identification number of the server, and the identification number of the server is composed of Arabic numerals. For example, if the identification number of the server is 233, the third identification is 233. What needs to know is that the third identifier is the unique identifier of the server.
  • Each server in the distributed server cluster is assigned a different identifier and the identifier assigned by each server is unique, for example, four in a distributed server cluster.
  • the server identifiers can be: 1, 2, 3, 4.
  • Step S022 Determine whether the first identifier, the second identifier, and the third identifier all meet the corresponding preset length.
  • the length of the first, second, and third identifiers means the number of digits in the first, second, and third identifiers. For example, when the first identifier is 1613024787541, the length is 13 Bit.
  • the first mark, the second mark, and the third mark are respectively set with their corresponding preset lengths. It should be known that the preset lengths corresponding to the first mark, the second mark, and the third mark will not be less than under normal circumstances.
  • the lengths of the first identification, the second identification and the third identification, and the preset lengths corresponding to the first identification, the second identification and the third identification may be the same or different.
  • the preset length corresponding to the first identifier is 13 bits
  • the preset length corresponding to the second identifier is 1 bit
  • the preset length corresponding to the third identifier is 5 bits.
  • the setting of the preset length of each of the above identifiers can basically meet the needs of various existing business scenarios. For example, setting the preset length corresponding to the second identifier to 1, can make a server can generate 10 firsts within 1 millisecond. The identification code fully meets the normal business needs.
  • this application is not limited to this, and the preset lengths corresponding to the first identifier, the second identifier, and the third identifier can be adjusted according to specific conditions.
  • Whether the length of the first mark/second mark/third mark meets the corresponding preset length is determined by judging whether the length of the first mark/second mark/third mark corresponds to the first mark/second mark/third mark Whether the preset lengths are equal to determine. For example, when the first identifier is 1613024787541, its length is 13 bits. If the preset length corresponding to the first identifier is also 13 bits, it is determined that the first identifier meets the corresponding preset length.
  • Step S023 If yes, splice the first mark, the second mark, and the third mark together according to the preset splicing sequence to form a first identification code.
  • the first splicing sequence the first mark, the second mark, and the third mark
  • the second splicing sequence the first Marking, third marking, second marking
  • third splicing order second marking, third marking, first marking
  • fourth splicing order second marking, first marking, third marking
  • fifth splicing order first marking
  • sixth splicing order third identification, second identification, first identification.
  • the first identification is 1613024787541
  • the second identification is 9
  • the third identification is 55444
  • the first identification, the second identification, and the third identification are all satisfied
  • the first identification code formed is: 1613024787541955444.
  • this application generates the first identification code according to the current timestamp and the number of visits in the current time unit and the identification number of the server, so that the generated first identification code will not generate identification collision distribution in the server cluster.
  • Each server in a modular server cluster can work at the same time, improving efficiency, and ensuring the uniqueness of the first identification code generated by multiple servers.
  • the preset lengths corresponding to the first identifier, the second identifier, and the third identifier are respectively configured to be at least greater than the length of the first identifier, at least greater than the length of the second identifier, and at least greater than the length of the third identifier.
  • the short link generation method further includes: if the first identification, the second identification, and the third identification do not all meet the corresponding preset length, then if the first identification and/or the second identification and/or the first identification and/or the second identification do not meet the preset length. Or add the numeric character 0 before the third identifier, so that the first identifier, the second identifier, and the third identifier all meet the corresponding preset length.
  • the first identifier is 3024787541
  • the preset length corresponding to the first identifier is 13 bits
  • the second identifier is 9
  • the preset length corresponding to the second identifier is 1 bit
  • the third identifier is: 544
  • the third identifier is The corresponding preset length is 5 digits.
  • the first identifier after the numeric character 0 is added is: 0003024787541
  • the third identifier after the numeric character 0 is added is 00544. If the preset splicing sequence is the first splicing sequence, the first identification code generated by splicing the first identification, the second identification, and the third identification together is: 0003024787541900544.
  • the first identification code is formed by splicing the first identification, the second identification, and the third identification.
  • This application defines the position of the three-segment identification in the first identification code by setting a preset number of digits (length), so that the three The segment identifiers change at their respective predetermined positions. Under the premise of ensuring normal business requirements, the generated first identifier code will not be repeated.
  • step S03 is performed: taking the first identification code as a decimal value, and converting the first identification code from a decimal value to a sixty binary value to obtain the second identification code.
  • the generated first identification code is 0001613024787541981316, and the first identification code is used as a decimal value, that is, the first identification code "0001613024787541981316" is used as the value "1613024787541981316", and then the first identification code is converted from decimal value to sixty binary value
  • the second identification code generated is: dITqmhw2He.
  • the first identification code is converted from decimal to sixty binary, so that the length of the first identification can be greatly shortened to meet the shortcoming requirements.
  • the conversion from decimal to sixty binary is compared to decimal to sixty-four.
  • the generated second identification code will not contain the characters "@" and the characters "#", which is relatively more Simplicity and at the same time can meet the needs of greatly shortening the length of the first logo, so that the user experience can be further improved.
  • step S04 is performed: a short link is generated according to the second identification code and the domain name in the long link, and the short link is returned to the terminal device.
  • generating the short link according to the second identification code and the domain name in the long link may include the following steps.
  • Step S041 Obtain a character set, where each character in the character set has a sixty binary one-to-one correspondence with each character in the second identification code.
  • 62 different characters are recorded in the character set, and the correspondence between each of the 62 different characters and one of the remaining 61 characters, and the character corresponding to each character is unique, with 62 different characters.
  • the characters include 26 lowercase letters, 26 uppercase letters, and 10 Arabic numerals.
  • the character corresponding to the uppercase letter “A” may be the Arabic numeral "4"
  • the character corresponding to the lowercase letter “b” may be the Arabic numeral "8”.
  • Step S042 Determine the character corresponding to each character in the second identification code in the character set, and convert each character in the second identification code to its corresponding character to generate a third identification code.
  • each character of the second identification code is respectively converted into a corresponding character according to the corresponding relationship on the character set to obtain the third identification code.
  • Step S043 The domain name in the long link and the third identification code are spliced together to form a short link.
  • the long link is: http:/domain1/poem_qianmo/article/details/52344732, therefore, the domain name of the long link is: domain1, if the generated third identifier is: Rtffvic, the final short link is: http:/ domain1/Rtffvic.
  • the security and privacy of the short link generation method provided in this application can be further effectively improved.
  • this application is only effective by further converting the second identification code to the third identification code. The above-mentioned situation is avoided and the security performance is increased.
  • the conversion rules are customized, can be set freely according to requirements, and can be changed at any time, the flexibility of the short link generation method in this application is improved.
  • the method further includes: establishing a corresponding relationship between the short link and the long link, using the short link as the key value, and the long link corresponding to the short link as the value Value, the key value and value value are stored as a pair of key-value pairs in the LRU (Least Recently Used) cache space.
  • LRU Least Recently Used
  • This application establishes and saves the corresponding relationship between the generated short link and the long link after the short link is generated, so that when a short link request is received, the short link carried in the short link request is analyzed to obtain the information in the short link request.
  • the key value according to the key value, judge whether there is a value value corresponding to the key value in the cache space, and if so, the value value is returned as a long link corresponding to the short link.
  • LRU cache space when the cache capacity reaches the upper limit, the LRU cache space will automatically delete the least recently used data value (key, value), thereby making it new Leave space for the data value of, realize the automatic elimination of the LRU mechanism, and achieve the beneficial effects of scalability and high availability.
  • This application provides a short link generation server 1, which includes the following modules.
  • the receiving module 11 is configured to receive a short link acquisition request sent by a terminal device, and the short link acquisition request includes a long link.
  • the first identification code generation module 12 is configured to generate a first identification code according to the current time, the number of short link acquisition requests received in the current time unit, and the identification number of the server, where the first identification code is composed of numeric characters.
  • the second identification code generation module 13 is configured to use the first identification code as a decimal value, and convert the first identification code from a decimal value to a sixty binary value to obtain the second identification code.
  • the short link generating module 14 is used to generate a short link according to the second identification code and the domain name in the long link, and return the short link to the terminal device.
  • the first identification code is generated according to the current time, the number of short link acquisition requests received in the current time unit, and the identification number of the server, and then the first identification code is converted to sixty-two in decimal. Base conversion to obtain the second identification code, and then generate the short link. Because the first identification code is generated according to the current time, the number of short link acquisition requests received in the current time unit and the identification number of the server, based on the variability of time In this way, it can be ensured that each generated first identification code has unique identification, and the short links generated for each long link are unique, thus avoiding the conflict of short links.
  • the first identification code generation module 12 may include the following units.
  • the first determining unit is used to determine the first identifier, the second identifier, and the third identifier, where the first identifier is the number of time units that are different from the preset start time unit, and the second identifier is determined by the current time unit
  • the number of short link acquisition requests received within is determined, and the third identifier is the identification number of the server, where the identification number of the server is composed of numeric characters.
  • the first determining unit is used to determine whether the first identifier, the second identifier, and the third identifier all meet the corresponding preset length.
  • the first splicing unit is used to splice the first mark, the second mark, and the third mark together according to the preset splicing sequence when the first mark, the second mark, and the third mark all meet the corresponding preset lengths to form The first identification code.
  • the first identification code generation module 12 may further include: a processing unit, configured to: when the first identification, the second identification, and the third identification do not all meet the corresponding preset length, when the first identification code does not meet the preset length Add the numeric character 0 before the first logo and/or the second logo and/or the third logo, so that the first logo, the second logo, and the third logo all meet the corresponding preset length; the second splicing unit is used for In the splicing sequence, the first identification, the second identification, and the third identification are spliced together to form the first identification code.
  • a processing unit configured to: when the first identification, the second identification, and the third identification do not all meet the corresponding preset length, when the first identification code does not meet the preset length Add the numeric character 0 before the first logo and/or the second logo and/or the third logo, so that the first logo, the second logo, and the third logo all meet the corresponding preset length; the second splicing unit is used for In the splicing
  • the receiving module 11 may include: a receiving unit for receiving a short link obtaining request from the requesting party, the short link obtaining request including a long link; and, an extracting unit, which extracts the domain name of the long link, and determines whether the domain name exists in the pre-order Set the domain name blacklist.
  • the short link generation module 14 may include: a character set obtaining unit for obtaining a character set, wherein each character in the character set has a sixty binary one-to-one correspondence with each character in the second identification code
  • the conversion unit is used to determine the corresponding character of each character in the second identification code in the character set, and convert each character in the second identification code to its corresponding character to form a third identification code; and, the third The splicing unit is used to splice the domain name in the long link with the third identification code to form a short link.
  • the short link generation server 1 may also include: a correspondence relationship establishment module, which is used to establish a correspondence relationship between a short link and a long link, using the short link as the key value, the long link corresponding to the short link as the value value, and the key The value and the value value are stored in the LRU cache space as a pair of key-value pairs.
  • a correspondence relationship establishment module which is used to establish a correspondence relationship between a short link and a long link, using the short link as the key value, the long link corresponding to the short link as the value value, and the key The value and the value value are stored in the LRU cache space as a pair of key-value pairs.
  • the embodiments of the present application also provide a storage medium, the storage medium includes a stored program, wherein the device where the storage medium is located is controlled to execute the short link generation method in any one or more embodiments of the present application when the program is running, in order to avoid repetition , I will not repeat them here.
  • the storage medium involved in this application may be a computer-readable storage medium, and the storage medium, such as a computer-readable storage medium, may be non-volatile or volatile.
  • an embodiment of the present application also provides a computer device 50.
  • the computer device 50 of this embodiment includes: a processor 51, a memory 52, and a computer stored in the memory 52 and running on the processor 51
  • the program 53, the computer program 53 is executed by the processor 51 to implement the short link generation method in the embodiment, in order to avoid repetition, it will not be repeated here.
  • the computer program is executed by the processor 51, the function of each model/unit in the short link generation server 1 in the embodiment is realized. In order to avoid repetition, it will not be repeated here.
  • the computer device 50 may be a computing device such as a desktop computer, a notebook, a palmtop computer, and a cloud server.
  • the computer device 50 may include but is not limited to a processor 51 and a memory 52.
  • FIG. 3 is only an example of the computer device 50, and does not constitute a limitation on the computer device 50. It may include more or less components than shown, or a combination of certain components, or different components.
  • computer equipment may also include input and output devices, network access devices, buses, and so on.
  • the so-called processor 51 may be a central processing unit (Central Processing Unit, CPU), and may also be other general-purpose processors, digital signal processors (Digital Signal Processor, DSP), and application specific integrated circuits (Application Specific Integrated Circuits). Specific Integrated Circuit (ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc.
  • the general-purpose processor may be a microprocessor or the processor may also be any conventional processor or the like.
  • the memory 52 may be an internal storage unit of the computer device 50, such as a hard disk or memory of the computer device 50.
  • the memory 52 may also be an external storage device of the computer device 50, such as a plug-in hard disk equipped on the computer device 50, a smart memory card (Smart Media Card, SMC), Secure Digital (SD) card, Flash Card, etc.
  • the memory 52 may also include both an internal storage unit of the computer device 50 and an external storage device.
  • the memory 52 is used to store computer programs and other programs and data required by the computer equipment.
  • the memory 52 can also be used to temporarily store data that has been output or will be output.
  • the disclosed system, device, and method may be implemented in other ways.
  • the device embodiments described above are merely illustrative.
  • the division of units is only a logical function division. In actual implementation, there may be other division methods.
  • multiple units or components may be combined or may be Integrate into another system, or some features can be ignored or not implemented.
  • the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
  • the functional units in the various embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
  • the above-mentioned integrated unit may be implemented in the form of hardware, or may be implemented in the form of hardware plus software functional units.
  • the above-mentioned integrated unit implemented in the form of a software functional unit may be stored in a computer readable storage medium.
  • the above-mentioned software functional unit is stored in a storage medium, and includes several instructions to make a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor (Processor) execute part of the steps of the methods in the various embodiments of the present application .
  • the aforementioned storage media include: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), Random Access Memory (Random Access Memory, RAM), magnetic disks or CD-ROMs and other media that can store program codes.

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

一种短链接的生成方法、服务器、存储介质及计算机设备,短链接的生成方法应用于服务器,该方法包括:接收请求方发送的短链接获取请求,短链接获取请求包括长链接(S01);根据当前时间、当前时间单位内接收到的短链接获取请求的数量及服务器的识别号生成第一标识码,其中,第一标识码由数字字符构成(S02);将第一标识码作为十进制数值,对第一标识码进行十进制数值到六十二进制数值的转换处理,得到第二标识码(S03);根据第二标识码及长链接中的域名生成短链接,并将短链接返回给终端设备(S04)。上述方法可以解决生成的短链接冲突的问题。

Description

短链接的生成方法、服务器、存储介质及计算机设备
本申请要求于2019年10月14日提交中国专利局、申请号为201910974469.8,发明名称为“短链接的生成方法、服务器、存储介质及计算机设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及基架运维领域,具体涉及一种短链接的生成方法、服务器、存储介质及计算机设备。
背景技术
短链接是指将长的统一资源定位符(Uniform Resource Locator,URL) 网址,通过程序计算等方式,转换为简短的网址字符串,从而达到节省字符数的目的。发明人意识到,现有的短链接生成方法是将原始长链接作为输入,通过哈希(hash)算法生成与原始长链接对应的短链接。当用户拿着短链接进行解析时,短链接会根据链接存储单元进行检索,并将原来的网址链接返还回来,进行地址重定向。
但发明人在研究中发现,虽然通过现有技术能够生成与原始长链接对应的短链接,然而,通过哈希算法自动生成短链接,而且受哈希算法的最多16位的进制限制,会出现对应不同长链接生成相同的短链接,造成短链接冲突,从而使得访问者访问短链接时发生访问错误。
技术问题
本申请实施例提供一种短链接的生成方法、服务器、存储介质及计算机设备,用于解决现有技术中的生成的短链接存在冲突的问题。
技术解决方案
第一方面,本申请实施例提供了一种短链接的生成方法,所述方法应用于服务器,所述方法包括:接收终端设备发送的短链接获取请求,所述短链接获取请求包括长链接;根据当前时间、当前时间单位内接收到的所述短链接获取请求的数量及所述服务器的识别号生成第一标识码,其中,所述第一标识码由数字字符构成;将所述第一标识码作为十进制数值,对所述第一标识码进行十进制数值到六十二进制数值的转换处理,得到第二标识码;根据所述第二标识码及所述长链接中的域名生成短链接,并将所述短链接返回给所述终端设备。
第二方面,本申请实施例提供了一种短链接生成服务器,包括:接收模块,用于接收终端设备发送的短链接获取请求,所述短链接获取请求包括长链接;第一标识码生成模块,用于根据当前时间、当前时间单位内接收到的所述短链接获取请求的数量及所述服务器的识别号生成第一标识码,其中,所述第一标识码由数字字符构成;第二标识码生成模块,用于将所述第一标识码作为十进制数值,对所述第一标识码进行十进制数值到六十二进制数值的转换处理,得到第二标识码;及,短链接生成模块,用于根据所述第二标识码及所述长链接中的域名生成短链接,并将所述短链接返回给所述终端设备。
第三方面,本申请实施例提供了一种存储介质,所述存储介质包括存储的程序,其中,在所述程序运行时控制所述存储介质所在设备执行上述方法,例如,执行以下步骤:接收终端设备发送的短链接获取请求,所述短链接获取请求包括长链接;根据当前时间、当前时间单位内接收到的所述短链接获取请求的数量及所述服务器的识别号生成第一标识码,其中,所述第一标识码由数字字符构成;将所述第一标识码作为十进制数值,对所述第一标识码进行十进制数值到六十二进制数值的转换处理,得到第二标识码;根据所述第二标识码及所述长链接中的域名生成短链接,并将所述短链接返回给所述终端设备。
第四方面,本申请实施例提供了一种计算机设备,包括存储器和处理器,所述存储器用于存储包括程序指令的信息,所述处理器用于控制程序指令的执行,所述程序指令被处理器加载并执行时实现上述方法的步骤,例如,实现以下步骤:接收终端设备发送的短链接获取请求,所述短链接获取请求包括长链接;根据当前时间、当前时间单位内接收到的所述短链接获取请求的数量及所述服务器的识别号生成第一标识码,其中,所述第一标识码由数字字符构成;将所述第一标识码作为十进制数值,对所述第一标识码进行十进制数值到六十二进制数值的转换处理,得到第二标识码;根据所述第二标识码及所述长链接中的域名生成短链接,并将所述短链接返回给所述终端设备。
有益效果
本申请实施例可以保证生成的每个第一标识码具有唯一的标识性,进而针对各个长链接产生的短链接都是唯一的,因此,避免了短链接的冲突。
附图说明
图1为本申请实施例提供的一种短链接的生成方法的流程图。
图2为本申请实施例提供的一种短链接生成服务器的示意框图。
图3为本申请实施例提供的一种计算机设备的示意框图。
本发明的实施方式
为了更好的理解本申请的技术方案,下面结合附图对本申请实施例进行详细描述。
本申请的技术方案可应用于人工智能或大数据技术领域,如可通过数据平台实现。
应当明确,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其它实施例,都属于本申请保护的范围。
在本申请实施例中使用的术语是仅仅出于描述特定实施例的目的,而非旨在限制本申请。在本申请实施例和所附权利要求书中所使用的单数形式的“一种”、“所述”和“该”也旨在包括多数形式,除非上下文清楚地表示其它含义。
应当理解,本文中使用的术语“和/或”仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。另外,本文中字符“/”,一般表示前后关联对象是一种“或”的关系。
请参阅附图1,本申请实施例提供一种短链接的生成方法,该方法应用于服务器,在本实施方式中,服务器为分布式服务器集群中的一个服务器,本申请实施例提供的短链接的生成方法包括以下步骤。
步骤S01:接收终端设备发送的短链接获取请求,短链接获取请求包括长链接。
步骤S02:根据当前时间、当前时间单位内接收到的短链接获取请求的数量及服务器的识别号生成第一标识码,其中,第一标识码由数字字符构成。
步骤S03:将第一标识码作为十进制数值,对第一标识码进行十进制数值到六十二进制数值的转换处理,得到第二标识码。
步骤S04:根据第二标识码及长链接中的域名生成短链接,并将短链接返回给终端设备。
可以理解,本申请实施例中,通过根据当前时间、当前时间单位内接收到的短链接获取请求的数量及服务器的识别号生成第一标识码,然后对第一标识码进行十进制到六十二进制的转换,得到第二标识码,进而生成短链接,由于第一标识码根据当前时间、当前时间单位内接收到的短链接获取请求的数量及服务器的识别号生成,基于时间的变化性,从而可以保证生成的每个第一标识码具有唯一的标识性,进而针对各个长链接产生的短链接都是唯一的,因此,避免了短链接的冲突。
下面再次结合附图1对本实施例提供的短链接的生成方法的具体技术方案进行详细的说明。
首先,执行步骤S01:接收终端设备发送的短链接获取请求,短链接获取请求包括长链接。
具体地,终端设备可以是系统端设备,也可以是普通用户的终端设备,还可以是合作伙伴设备等。其中,终端设备可以包括各种智能手机、平板电脑、个人计算机(Personal Computer,PC)等。
在本申请实施方式中,由服务器接收终端设备发送的短链接获取请求,该服务器可以是分布式服务器集群中的任一服务器。
在本申请实施方式中,短链接获取请求还可以终端设备对应的用户信息,用户信息可以是用户自定义的描述信息,例如可以是用户的类型标识、用户的属地标识或者其他信息等。
一个完整的长链接由传输协议、域名、路径名、文件名等构成,例如:http://wenwen.soso.com/z/q136244386.htm?cid=ti.k.a.n,其中,http是超文本传输协议,wenwen.soso.com是域名,z/是路径名,q136244386.htm?cid=ti.k.a.n是文件名。
优选地,接收请求方的短链接获取请求,可以包括以下步骤。
步骤S011:接收请求方的短链接获取请求,短链接获取请求包括长链接。
步骤S012:提取长链接的域名,判断域名是否存在于预设的域名黑名单中。
步骤S013:若否,则根据当前时间、当前时间单位内接收到的短链接获取请求的数量及服务器的识别号生成第一标识码。
具体地,域名黑名单中记录有不被该服务器允许访问的域名标识,若该服务器接收到的短链接获取请求中携带的长链接对应的域名存在于域名黑名单中,则服务器返回错误信息或者无法进行访问的信息。
可以理解,通过设置域名黑名单与长链接的域名进行对比,可以对待转换的长链接进行安全校验,当短链接获取请求携带的长链接的域名不符合要求时不允进行转换,可以增加本申请提供的短链接的生成方法的安全性。
其次,执行步骤S02:根据当前时间、当前时间单位内接收到的短链接获取请求的数量及服务器的识别号生成第一标识码,其中,第一标识码由数字字符构成。
需要知道的是,第一标识码的生成方法与长链接无关。
可选地,根据当前时间、当前时间单位内接收到的短链接获取请求的数量及服务器的识别号生成第一标识码,具体包括以下步骤。
步骤S021:确定第一标识、第二标识及第三标识,其中,第一标识为当前时间单位与预设的开始时间单位相差的时间单位的数量,第二标识由当前时间单位内接收到的短链接获取请求的数量确定,第三标识为服务器的识别号,其中,服务器的识别号由数字字符构成。
具体地,时间单位可以为毫秒、秒、分钟、小时等,具体根据需求来定,在本实施方式中,时间单位为毫秒,例如,若当前时间与预设的开始时间相差1613024787541毫秒时,第一标识为:1613024787541。
当前时间可以为本地的标准时间,例如北京时间为:2009年1月1日0时0分0秒0毫秒,开始时间可以预先设置,例如:2000年1月1日0时0分0秒0毫秒。
第二标识由当前时间单位内接收到的短链接获取请求的数量确定,例如,在当前毫秒内,服务器接收到8次短链接获取请求,则第二标识为:8。
第三标识为服务器的识别号,服务器的识别号由阿拉伯数字字符构成,例如若服务器的识别号为:233,则第三标识为:233。需要知道的是,第三标识为服务器的唯一标识,分布式服务器集群中的每个服务器分配有不同的标识且每个服务器分配的标识都是唯一的,例如,分布式服务器集群中的四台服务器的标识可以分别为:1,2,3,4。
步骤S022:判断第一标识、第二标识及第三标识是否均满足对应的预设长度。
需要知道的是,第一标识、第二标识及第三标识的长度意指第一标识、第二标识及第三标识的位数,例如,当第一标识为:1613024787541时,其长度为13位。
第一标识、第二标识及第三标识分别设置有其对应的预设长度,需要知道的是,第一标识、第二标识及第三标识对应的预设长度在正常情况下均不会小于第一标识、第二标识及第三标识的长度,第一标识、第二标识及第三标识对应的预设长度可以相同也可以不同。在本实施方式中,第一标识对应的预设长度为13位,第二标识对应的预设长度为1位,第三标识对应的预设长度为5位。
上述各个标识的预设长度的设置能够基本满足现有的各个业务场景的需求,例如,设置第二标识对应的预设长度为1,可以使得一台服务器在1毫秒内可以产生10个第一标识码,完全满足正常的业务需求。当然,本申请不限于此,第一标识、第二标识及第三标识对应的预设长度可以根据具体情况进行调整。
第一标识/第二标识/第三标识的长度是否满足对应的预设长度通过判断第一标识/第二标识/第三标识的长度是否与第一标识/第二标识/第三标识对应的预设长度是否相等来确定。例如,当第一标识为:1613024787541时,其长度为13位,若第一标识对应的预设长度同样为13位,即确定第一标识满足对应的预设长度。
步骤S023:若是,则根据预设拼接顺序将第一标识、第二标识及第三标识拼接在一起,形成第一标识码。
具体地,第一标识、第二标识及第三标识之间可以有6种拼接顺序,分别为:第一拼接顺序:第一标识、第二标识、第三标识;第二拼接顺序:第一标识、第三标识、第二标识;第三拼接顺序:第二标识、第三标识、第一标识;第四拼接顺序:第二标识、第一标识、第三标识;第五拼接顺序:第三标识、第一标识、第二标识;第六拼接顺序:第三标识、第二标识、第一标识。
可以选取以上任意一种拼接顺序作为预设拼接顺序。
例如,以预设拼接顺序为第一拼接顺序为例,若第一标识为:1613024787541,第二标识为9,第三标识为:55444,在第一标识、第二标识、第三标识均满足对应地预设长度的条件下,按照第一拼接顺序将第一标识、第二标识及第三标识拼接在一起,形成的第一标识码为:1613024787541955444。
可以理解,本申请通过根据当前时间戳以及结合在当前时间单位内的访问数量以及服务器的标识号生成第一标识码,使得生成的第一标识码在服务器集群当中不会不会产生标识碰撞分布式服务器集群中各个服务器可以同时工作,提高效率,且能保证多个服务器生成的第一标识码的唯一性。
需要知道的是,第一标识、第二标识及第三标识对应的预设长度分别被配置为至少大于第一标识的长度、至少大于第二标识的长度及至少大于第三标识的长度。
进一步地,短链接生成方法还包括:若第一标识、第二标识及第三标识没有均满足对应的预设长度,则在没有满足预设长度的第一标识及/或第二标识及/或第三标识前添加数字字符0,使得第一标识、第二标识及第三标识均满足对应的预设长度。
例如,第一标识为:3024787541,第一标识对应的预设长度为13位,第二标识为:9,第二标识对应的预设长度为1位,第三标识为:544,第三标识对应的预设长度为5位。通过判断可以知道,第一标识及第三标识没有满足对应的预设长度,因此,需要在第一标识及第三标识前添加数字字符0,直到第一标识、第二标识及第三标识均满足对应的预设长度,具体地,进行添加数字字符0处理后的第一标识为:0003024787541,进行添加数字字符0处理后的第三标识为:00544。若预先设置的拼接顺序为第一拼接顺序,则将第一标识、第二标识及第三标识拼接在一起生成的第一标识码为:0003024787541900544。
可以理解,第一识别码通过第一标识、第二标识及第三标识拼接而成,本申请通过设置预设的位数(长度)限定三段标识在第一标识码中的位置,使得三段标识在各自的预定位置上变化,在保证业务正常需求的前提下,生成的第一标识码不会出现重复的现象。
其次,执行步骤S03:将第一标识码作为十进制数值,对第一标识码进行十进制数值到六十二进制数值的转换处理,得到第二标识码。
例如,生成的第一标识码为0001613024787541981316,将第一标识码作为十进制数值,即将第一标识码“0001613024787541981316”作为数值“1613024787541981316”,然后对第一标识码进行十进制数值到六十二进制数值的运算处理,进而生成的第二标识码为:dITqmhw2He。
可以理解,通过设置六十二进制算法将第一标识码作为十进制数值,对第一标识码进行十进制到六十二进制的转换运算,进而可以大幅缩短第一标识的长度,以满足短链接的需求。除此之外,十进制到六十二进制的转换相对于十进制到六十四进制而言,生成的第二标识码不会出现字符“@”及字符“#”,相对来说更为简洁同时又能满足大幅缩短第一标识的长度的需求,因此能够进一步提高用户体验。
然后,执行步骤S04:根据第二标识码及长链接中的域名生成短链接,并将短链接返回给终端设备。
进一步地,为了增加生成的短链接的安全性,根据第二标识码及长链接中的域名生成短链接,可以包括以下步骤。
步骤S041:获取字符集,其中字符集中的每个字符与第二标识码中的每个字符存在六十二进制的一一对应关系。
具体地,字符集上记载有62个不同字符,以及62个不同字符中的每个字符与其余61个字符中的一个字符的对应关系,且每个字符对应的字符是唯一的,62个不同字符包括26个小写字母、26个大写字母以及10个阿拉伯数字。
例如,大写字母“A”对应的字符可以为阿拉伯数字“4”,小写字母“b”对应的字符可以为阿拉伯数字“8”。
步骤S042:确定第二标识码中每个字符在字符集中对应的字符,并将第二标识码中每个字符转换为其对应的字符,生成第三标识码。
具体地,根据字符集上的对应关系将第二标识码的每个字符分别转化为对应的字符,得到第三标识码。
步骤S043:将长链接中的域名与第三标识码拼接在一起,形成短链接。
例如,长链接为:http:/domain1/poem_qianmo/article/details/52344732,因此,长链接的域名为:domain1,若生成的第三标识为:Rtffvic,则最终得到的短链接为:http:/domain1/Rtffvic。
可以理解,通过根据字符集将第二标识码进行转换形成第三标识码,可以进一步有效的提高本申请中提供的短链接生成方法的安全性及私密性,例如,他人在获取到短链接后容易根据获取到的短链接知道该服务器在一个时间单位内生成的短链接的数量,进而可能造成业务数据的泄露,因此,本申请通过将第二标识码进一步转换为第三标识码仅以有效避免上述情况的发生,增加了安全性能,同时,由于转换的规则是自定义的,可以根据需求自由设置,且可以随时更改,因此又提高了本申请中的短链接生成方法的灵活性。
进一步地,在根据第二标识码及长链接中的域名生成短链接之后,方法还包括:建立短链接与长链接的对应关系,将短链接作为key值,将短链接对应的长链接作为value值,将key值和value值作为一对键值对存入LRU(Least Recently Used,最少使用页面置换算法)缓存空间中。
本申请通过在生成短链接后,建立生成的短链接与长链接的对应关系并保存,使得当接收到短链接请求时,通过对短链接请求携带的短链接进行解析,获取短链接请求中的key值,根据key值,判断缓存空间是否有与key值对应的value值,若是,则将value值作为与短链接对应的长链接返回。
可以理解,通过采用一定大小的LRU缓存空间来存储短链接和长链接的对应关系,当缓存容量达到上限时,LRU缓存空间会自动删除最近最少使用的数据值(key,value),从而为新的数据值留出空间,实现了LRU机制的自动淘汰,可以取得可伸缩和高可用的有益效果。
请参阅附图2,本申请提供一种短链接生成服务器1,包括以下模块。
接收模块11,用于接收终端设备发送的短链接获取请求,短链接获取请求包括长链接。
第一标识码生成模块12,用于根据当前时间、当前时间单位内接收到的短链接获取请求的数量及服务器的识别号生成第一标识码,其中,第一标识码由数字字符构成。
第二标识码生成模块13,用于将第一标识码作为十进制数值,对第一标识码进行十进制数值到六十二进制数值的转换处理,得到第二标识码。
短链接生成模块14,用于根据第二标识码及长链接中的域名生成短链接,并将短链接返回给终端设备。
可以理解,本申请实施例中,通过根据当前时间、当前时间单位内接收到的短链接获取请求的数量及服务器的识别号生成第一标识码,然后对第一标识码进行十进制到六十二进制的转换,得到第二标识码,进而生成短链接,由于第一标识码根据当前时间、当前时间单位内接收到的短链接获取请求的数量及服务器的识别号生成,基于时间的变化性,从而可以保证生成的每个第一标识码具有唯一的标识性,进而针对各个长链接产生的短链接都是唯一的,因此,避免了短链接的冲突。
可选地,第一标识码生成模块12可以包括以下单元。
第一确定单元,用于确定第一标识、第二标识及第三标识,其中,第一标识为当前时间单位与预设的开始时间单位相差的时间单位的数量,第二标识由当前时间单位内接收到的短链接获取请求的数量确定,第三标识为服务器的识别号,其中,服务器的识别号由数字字符构成。
第一判断单元,用于判断第一标识、第二标识及第三标识是否均满足对应的预设长度。
第一拼接单元,用于当第一标识、第二标识及第三标识均满足对应的预设长度时,根据预设拼接顺序将第一标识、第二标识及第三标识拼接在一起,形成第一标识码。
可选地,第一标识码生成模块12还可以包括:处理单元,用于当第一标识、第二标识及第三标识没有均满足对应的预设长度时,在没有满足预设长度的第一标识及/或第二标识及/或第三标识前添加数字字符0,使得第一标识、第二标识及第三标识均满足对应的预设长度;第二拼接单元,用于根据预设拼接顺序将第一标识、第二标识及第三标识拼接在一起形成第一标识码。
可选地,接收模块11可以包括:接收单元,用于接收请求方的短链接获取请求,短链接获取请求包括长链接;及,提取单元,提取长链接的域名,并判断域名是否存在于预设的域名黑名单中。
可选地,短链接生成模块14可以包括:字符集获取单元,用于获取字符集,其中字符集中的每个字符与第二标识码中的每个字符存在六十二进制的一一对应关系;转换单元,用于确定第二标识码中每个字符在字符集中对应的字符,并将第二标识码中每个字符转换为其对应的字符,形成第三标识码;及,第三拼接单元,用于将长链接中的域名与第三标识码拼接在一起,形成短链接。
可选地,短链接生成服务器1还可以包括:对应关系建立模块,用于建立短链接与长链接的对应关系,将短链接作为key值,将短链接对应的长链接作为value值,将key值和value值作为一对键值对存入LRU缓存空间中。
本申请实施例还提供了一种存储介质,存储介质包括存储的程序,其中,在程序运行时控制存储介质所在设备执行本申请任一个或多个实施例中的短链接生成方法,为避免重复,此处不一一赘述。可选的,本申请涉及的存储介质可以是计算机可读存储介质,该存储介质如计算机可读存储介质可以是非易失性的,也可以是易失性的。
请参阅附图3,本申请实施例还提供了一种计算机设备50,该实施例的计算机设备50包括:处理器51、存储器52以及存储在存储器52中并可在处理器51上运行的计算机程序53,该计算机程序53被处理器51执行时实现实施例中的短链接生成方法,为避免重复,此处不一一赘述。或者,该计算机程序被处理器51执行时实现实施例中短链接生成服务器1中各模型/单元的功能,为避免重复,此处不一一赘述。
计算机设备50可以是桌上型计算机、笔记本、掌上电脑及云端服务器等计算设备。计算机设备50可包括但不仅限于处理器51、存储器52。本领域技术人员可以理解,图3仅仅是计算机设备50的示例,并不构成对计算机设备50的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件,例如计算机设备还可以包括输入输出设备、网络接入设备、总线等。
所称处理器51可以是中央处理单元(Central Processing Unit,CPU),还可以是其它通用处理器、数字信号处理器 (Digital Signal Processor,DSP)、专用集成电路 (Application Specific Integrated Circuit,ASIC)、现场可编程门阵列 (Field-Programmable Gate Array,FPGA) 或者其它可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。
存储器52可以是计算机设备50的内部存储单元,例如计算机设备50的硬盘或内存。存储器52也可以是计算机设备50的外部存储设备,例如计算机设备50上配备的插接式硬盘,智能存储卡(Smart Media Card, SMC),安全数字(Secure Digital, SD)卡,闪存卡(Flash Card)等。进一步地,存储器52还可以既包括计算机设备50的内部存储单元也包括外部存储设备。存储器52用于存储计算机程序以及计算机设备所需的其它程序和数据。存储器52还可以用于暂时地存储已经输出或者将要输出的数据。
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统,装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
在本申请所提供的几个实施例中,应该理解到,所揭露的系统,装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如,多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用硬件加软件功能单元的形式实现。
上述以软件功能单元的形式实现的集成的单元,可以存储在一个计算机可读取存储介质中。上述软件功能单元存储在一个存储介质中,包括若干指令用以使得一台计算机装置(可以是个人计算机,服务器,或者网络装置等)或处理器(Processor)执行本申请各个实施例方法的部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。
以上仅为本申请的较佳实施例而已,并不用以限制本申请,凡在本申请的精神和原则之内,所做的任何修改、等同替换、改进等,均应包含在本申请保护的范围之内。

Claims (20)

  1. 一种短链接的生成方法,其中,所述方法应用于服务器,所述方法包括:
    接收终端设备发送的短链接获取请求,所述短链接获取请求包括长链接;
    根据当前时间、当前时间单位内接收到的所述短链接获取请求的数量及所述服务器的识别号生成第一标识码,其中,所述第一标识码由数字字符构成;
    将所述第一标识码作为十进制数值,对所述第一标识码进行十进制数值到六十二进制数值的转换处理,得到第二标识码;
    根据所述第二标识码及所述长链接中的域名生成短链接,并将所述短链接返回给所述终端设备。
  2. 根据权利要求1所述的短链接的生成方法,其中,所述根据当前时间、当前时间单位内接收到的所述短链接获取请求的数量及所述服务器的识别号生成第一标识码,具体包括:
    确定第一标识、第二标识及第三标识,其中,所述第一标识为当前时间单位与预设的开始时间单位相差的时间单位的数量,所述第二标识由所述当前时间单位内接收到的所述短链接获取请求的数量确定,所述第三标识为所述服务器的识别号,其中,所述服务器的识别号由数字字符构成;
    判断所述第一标识、所述第二标识及所述第三标识是否均满足对应的预设长度;
    若是,则根据预设拼接顺序将所述第一标识、所述第二标识及所述第三标识拼接在一起,形成所述第一标识码。
  3. 根据权利要求2所述的短链接的生成方法,其中,所述方法还包括:
    若所述第一标识、所述第二标识及所述第三标识没有均满足对应的预设长度,则在没有满足预设长度的所述第一标识及/或所述第二标识及/或所述第三标识前添加数字字符0,使得所述第一标识、所述第二标识及所述第三标识均满足对应的预设长度;
    根据所述预设拼接顺序将所述第一标识、所述第二标识及所述第三标识拼接在一起形成所述第一标识码。
  4. 根据权利要求1所述的短链接的生成方法,其中,所述接收终端设备的短链接获取请求,具体包括:
    接收所述终端设备的短链接获取请求,所述短链接获取请求包括长链接;
    提取所述长链接中的域名,并判断所述域名是否存在于预设的域名黑名单中;
    若否,则根据当前时间、当前时间单位内接收到的所述短链接获取请求的数量及所述服务器的识别号生成第一标识码。
  5. 根据权利要求1或4所述的短链接的生成方法,其中,所述根据所述第二标识码及所述长链接中的域名生成短链接,具体包括:
    获取字符集,所述字符集中的每个字符与所述第二标识码中的每个字符存在六十二进制的一一对应关系;
    确定所述第二标识码中每个字符在所述字符集中对应的字符,并将所述第二标识码中每个字符转换为其对应的字符,生成第三标识码;
    将所述长链接中的域名与所述第三标识码拼接在一起,形成所述短链接。
  6. 根据权利要求1所述的短链接的生成方法,其中,在所述根据所述第二标识码及所述长链接中的域名生成短链接之后,所述方法还包括:
    建立所述短链接与所述长链接的对应关系,将所述短链接作为key值,将所述短链接对应的长链接作为value值,将所述key值和value值作为一对键值对存入LRU缓存空间中。
  7. 一种短链接生成服务器,其中,包括:
    接收模块,用于接收终端设备发送的短链接获取请求,所述短链接获取请求包括长链接;
    第一标识码生成模块,用于根据当前时间、当前时间单位内接收到的所述短链接获取请求的数量及所述服务器的识别号生成第一标识码,其中,所述第一标识码由数字字符构成;
    第二标识码生成模块,用于将所述第一标识码作为十进制数值,对所述第一标识码进行十进制数值到六十二进制数值的转换处理,得到第二标识码;及
    短链接生成模块,用于根据所述第二标识码及所述长链接中的域名生成短链接,并将所述短链接返回给所述终端设备。
  8. 如权利要求7所述的服务器,其中,所述第一标识码生成模块包括:
    第一确定单元,用于确定第一标识、第二标识及第三标识,其中,所述第一标识为当前时间单位与预设的开始时间单位相差的时间单位的数量,所述第二标识由所述当前时间单位内接收到的所述短链接获取请求的数量确定,所述第三标识为所述服务器的识别号,其中,所述服务器的识别号由数字字符构成;
    第一判断单元,用于判断所述第一标识、所述第二标识及所述第三标识是否均满足对应的预设长度;及
    第一拼接单元,用于当所述第一标识、所述第二标识及所述第三标识均满足对应的预设长度时,根据预设拼接顺序将所述第一标识、所述第二标识及所述第三标识拼接在一起,形成所述第一标识码。
  9. 一种存储介质,其中,所述存储介质包括存储的程序,其中,在所述程序运行时控制所述存储介质所在设备执行以下步骤:
    接收终端设备发送的短链接获取请求,所述短链接获取请求包括长链接;
    根据当前时间、当前时间单位内接收到的所述短链接获取请求的数量及服务器的识别号生成第一标识码,其中,所述第一标识码由数字字符构成;
    将所述第一标识码作为十进制数值,对所述第一标识码进行十进制数值到六十二进制数值的转换处理,得到第二标识码;
    根据所述第二标识码及所述长链接中的域名生成短链接,并将所述短链接返回给所述终端设备。
  10. 根据权利要求9所述的存储介质,其中,所述根据当前时间、当前时间单位内接收到的所述短链接获取请求的数量及所述服务器的识别号生成第一标识码时,具体执行以下步骤:
    确定第一标识、第二标识及第三标识,其中,所述第一标识为当前时间单位与预设的开始时间单位相差的时间单位的数量,所述第二标识由所述当前时间单位内接收到的所述短链接获取请求的数量确定,所述第三标识为所述服务器的识别号,其中,所述服务器的识别号由数字字符构成;
    判断所述第一标识、所述第二标识及所述第三标识是否均满足对应的预设长度;
    若是,则根据预设拼接顺序将所述第一标识、所述第二标识及所述第三标识拼接在一起,形成所述第一标识码。
  11. 根据权利要求10所述的存储介质,其中,在所述程序运行时还控制所述存储介质所在设备执行以下步骤:
    若所述第一标识、所述第二标识及所述第三标识没有均满足对应的预设长度,则在没有满足预设长度的所述第一标识及/或所述第二标识及/或所述第三标识前添加数字字符0,使得所述第一标识、所述第二标识及所述第三标识均满足对应的预设长度;
    根据所述预设拼接顺序将所述第一标识、所述第二标识及所述第三标识拼接在一起形成所述第一标识码。
  12. 根据权利要求9所述的存储介质,其中,所述接收终端设备的短链接获取请求时,具体执行以下步骤:
    接收所述终端设备的短链接获取请求,所述短链接获取请求包括长链接;
    提取所述长链接中的域名,并判断所述域名是否存在于预设的域名黑名单中;
    若否,则根据当前时间、当前时间单位内接收到的所述短链接获取请求的数量及所述服务器的识别号生成第一标识码。
  13. 根据权利要求9或12所述的存储介质,其中,所述根据所述第二标识码及所述长链接中的域名生成短链接时,具体执行以下步骤:
    获取字符集,所述字符集中的每个字符与所述第二标识码中的每个字符存在六十二进制的一一对应关系;
    确定所述第二标识码中每个字符在所述字符集中对应的字符,并将所述第二标识码中每个字符转换为其对应的字符,生成第三标识码;
    将所述长链接中的域名与所述第三标识码拼接在一起,形成所述短链接。
  14. 根据权利要求9所述的存储介质,其中,在所述根据所述第二标识码及所述长链接中的域名生成短链接之后,在所述程序运行时还控制所述存储介质所在设备执行以下步骤:
    建立所述短链接与所述长链接的对应关系,将所述短链接作为key值,将所述短链接对应的长链接作为value值,将所述key值和value值作为一对键值对存入LRU缓存空间中。
  15. 一种计算机设备,包括存储器和处理器,所述存储器用于存储包括程序指令的信息,所述处理器用于控制程序指令的执行,其中:所述程序指令被处理器加载并执行时实现以下步骤:
    接收终端设备发送的短链接获取请求,所述短链接获取请求包括长链接;
    根据当前时间、当前时间单位内接收到的所述短链接获取请求的数量及服务器的识别号生成第一标识码,其中,所述第一标识码由数字字符构成;
    将所述第一标识码作为十进制数值,对所述第一标识码进行十进制数值到六十二进制数值的转换处理,得到第二标识码;
    根据所述第二标识码及所述长链接中的域名生成短链接,并将所述短链接返回给所述终端设备。
  16. 根据权利要求15所述的计算机设备,其中,所述根据当前时间、当前时间单位内接收到的所述短链接获取请求的数量及所述服务器的识别号生成第一标识码时,具体实现以下步骤:
    确定第一标识、第二标识及第三标识,其中,所述第一标识为当前时间单位与预设的开始时间单位相差的时间单位的数量,所述第二标识由所述当前时间单位内接收到的所述短链接获取请求的数量确定,所述第三标识为所述服务器的识别号,其中,所述服务器的识别号由数字字符构成;
    判断所述第一标识、所述第二标识及所述第三标识是否均满足对应的预设长度;
    若是,则根据预设拼接顺序将所述第一标识、所述第二标识及所述第三标识拼接在一起,形成所述第一标识码。
  17. 根据权利要求16所述的计算机设备,其中,所述程序指令被处理器加载并执行时还实现以下步骤:
    若所述第一标识、所述第二标识及所述第三标识没有均满足对应的预设长度,则在没有满足预设长度的所述第一标识及/或所述第二标识及/或所述第三标识前添加数字字符0,使得所述第一标识、所述第二标识及所述第三标识均满足对应的预设长度;
    根据所述预设拼接顺序将所述第一标识、所述第二标识及所述第三标识拼接在一起形成所述第一标识码。
  18. 根据权利要求15所述的计算机设备,其中,所述接收终端设备的短链接获取请求时,具体实现以下步骤:
    接收所述终端设备的短链接获取请求,所述短链接获取请求包括长链接;
    提取所述长链接中的域名,并判断所述域名是否存在于预设的域名黑名单中;
    若否,则根据当前时间、当前时间单位内接收到的所述短链接获取请求的数量及所述服务器的识别号生成第一标识码。
  19. 根据权利要求15或18所述的计算机设备,其中,所述根据所述第二标识码及所述长链接中的域名生成短链接时,具体实现以下步骤:
    获取字符集,所述字符集中的每个字符与所述第二标识码中的每个字符存在六十二进制的一一对应关系;
    确定所述第二标识码中每个字符在所述字符集中对应的字符,并将所述第二标识码中每个字符转换为其对应的字符,生成第三标识码;
    将所述长链接中的域名与所述第三标识码拼接在一起,形成所述短链接。
  20. 根据权利要求15所述的计算机设备,其中,在所述根据所述第二标识码及所述长链接中的域名生成短链接之后,所述程序指令被处理器加载并执行时还实现以下步骤:
    建立所述短链接与所述长链接的对应关系,将所述短链接作为key值,将所述短链接对应的长链接作为value值,将所述key值和value值作为一对键值对存入LRU缓存空间中。
PCT/CN2020/099251 2019-10-14 2020-06-30 短链接的生成方法、服务器、存储介质及计算机设备 WO2021073156A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910974469.8A CN110851748A (zh) 2019-10-14 2019-10-14 短链接的生成方法、服务器、存储介质及计算机设备
CN201910974469.8 2019-10-14

Publications (1)

Publication Number Publication Date
WO2021073156A1 true WO2021073156A1 (zh) 2021-04-22

Family

ID=69597554

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/099251 WO2021073156A1 (zh) 2019-10-14 2020-06-30 短链接的生成方法、服务器、存储介质及计算机设备

Country Status (2)

Country Link
CN (1) CN110851748A (zh)
WO (1) WO2021073156A1 (zh)

Families Citing this family (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112307058B (zh) * 2020-10-27 2024-03-15 北京水滴科技集团有限公司 短链接的处理方法、装置、存储介质及计算机设备
CN112380464B (zh) * 2020-11-10 2023-07-28 中国平安人寿保险股份有限公司 一种短链接生成方法以及相关设备
CN112417326B (zh) * 2020-11-20 2024-07-26 百度在线网络技术(北京)有限公司 Url的转换方法和装置、电子设备和存储介质
CN112487317A (zh) * 2020-11-23 2021-03-12 中国人寿保险股份有限公司 一种统一资源定位符转换方法、装置、设备及介质
CN112883301A (zh) * 2021-02-03 2021-06-01 叮当快药科技集团有限公司 基于55进制的短链接生成方法、装置及存储介质
CN113378083B (zh) * 2021-05-19 2023-09-29 北京沃东天骏信息技术有限公司 一种短链接生成方法、装置、设备及存储介质
CN113676562B (zh) * 2021-08-17 2022-10-14 平安普惠企业管理有限公司 短链请求收敛方法、装置、计算机设备和存储介质
CN113761406B (zh) * 2021-09-03 2024-06-04 丰巢网络技术有限公司 一种智能柜二维码短链生成方法、装置、介质及电子设备
CN115391689B (zh) * 2022-08-23 2023-08-22 北京泰镝科技股份有限公司 一种短链接生成方法、装置、设备及存储介质
CN116938871B (zh) * 2023-09-18 2023-11-28 北京木屋时代科技有限公司 一种域名短码确定方法、装置、存储介质及电子装置

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107612692A (zh) * 2017-09-25 2018-01-19 咪咕文化科技有限公司 一种信息处理方法、装置及存储介质
CN107729409A (zh) * 2017-09-26 2018-02-23 中国银联股份有限公司 一种短链接生成方法及装置
US10187447B1 (en) * 2016-01-28 2019-01-22 Twitter, Inc. Method and system for online conversion attribution
CN110134889A (zh) * 2019-04-30 2019-08-16 中国联合网络通信集团有限公司 短链接生成方法、装置及服务器

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104601736B (zh) * 2013-10-30 2018-10-23 腾讯科技(深圳)有限公司 一种短url服务的实现方法及装置
CN105630927B (zh) * 2015-12-22 2019-06-18 北京奇虎科技有限公司 链接生成方法和装置
CN107749861A (zh) * 2017-11-16 2018-03-02 平安科技(深圳)有限公司 信息推送方法、装置、终端设备及存储介质

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10187447B1 (en) * 2016-01-28 2019-01-22 Twitter, Inc. Method and system for online conversion attribution
CN107612692A (zh) * 2017-09-25 2018-01-19 咪咕文化科技有限公司 一种信息处理方法、装置及存储介质
CN107729409A (zh) * 2017-09-26 2018-02-23 中国银联股份有限公司 一种短链接生成方法及装置
CN110134889A (zh) * 2019-04-30 2019-08-16 中国联合网络通信集团有限公司 短链接生成方法、装置及服务器

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
DA TIAN GOU ZI: "Java Tools: URL Shortener based on SnowFlake", 4 January 2019 (2019-01-04), XP009527460, Retrieved from the Internet <URL:https://www.cnblogs.com/datiangou/p/10222352.html> *
ZAI LU SHANG DE XIAO HAI ZEI: "Shortened URL Service-Oriented Architecture Design and Uses", 28 November 2018 (2018-11-28), XP009527459, Retrieved from the Internet <URL:https://www.jianshu.com/p/6ec922d79115> *

Also Published As

Publication number Publication date
CN110851748A (zh) 2020-02-28

Similar Documents

Publication Publication Date Title
WO2021073156A1 (zh) 短链接的生成方法、服务器、存储介质及计算机设备
CN108494775B (zh) 防止利用合法数据或篡改合法数据进行网络攻击的方法
CN111274268A (zh) 物联网数据传输方法、装置、介质及电子设备
WO2020233033A1 (zh) 信息交互方法、装置及存储介质
WO2021223662A1 (zh) 基于扫码的页面访问
CN111949974A (zh) 一种认证的方法、装置、计算机设备及存储介质
WO2018018697A1 (zh) 伪基站垃圾短信鉴别方法及系统
US20120240184A1 (en) System and method for on the fly protocol conversion in obtaining policy enforcement information
WO2018161881A1 (zh) 结构化数据的处理方法、存储介质和计算机设备
US20170155712A1 (en) Method and device for updating cache data
WO2022237569A1 (zh) 一种交易验重方法、装置、设备以及介质
US20230259938A1 (en) Blockchain-based data processing method and apparatus, device, readable storage medium and computer program product
CN112511316A (zh) 单点登录接入方法、装置、计算机设备及可读存储介质
US11368297B2 (en) Method and apparatus for updating digital certificate
CN110781676B (zh) 一种文本处理方法、装置、系统、电子设备及存储介质
CN112235104A (zh) 一种数据加密传输方法、系统、终端及存储介质
CN113378095B (zh) 签名算法的动态加载方法、装置、设备及存储介质
CN114513350A (zh) 身份校验方法、系统和存储介质
CN107707686A (zh) 设备标识方法和装置
CN116932421A (zh) 一种数据存储方法、装置、设备及存储介质
CN114793244B (zh) 一种区块链的资源处理方法、装置、设备和介质
WO2023071893A1 (zh) 一种基于三种模式的数据压缩方法和数据解压方法
CN116055403A (zh) 报文数据的传输方法、装置和服务器
TW201533593A (zh) 對網路位址進行處理的方法及相關的伺服器與非暫態電腦可讀取儲存媒體
CN113888170A (zh) 地址溯源方法、装置及设备

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: 20877540

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20877540

Country of ref document: EP

Kind code of ref document: A1