CN110134889B - Short link generation method and device and server - Google Patents

Short link generation method and device and server Download PDF

Info

Publication number
CN110134889B
CN110134889B CN201910362089.9A CN201910362089A CN110134889B CN 110134889 B CN110134889 B CN 110134889B CN 201910362089 A CN201910362089 A CN 201910362089A CN 110134889 B CN110134889 B CN 110134889B
Authority
CN
China
Prior art keywords
character string
converted
link
long
server
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.)
Active
Application number
CN201910362089.9A
Other languages
Chinese (zh)
Other versions
CN110134889A (en
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.)
China United Network Communications Group Co Ltd
Original Assignee
China United Network Communications Group 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 China United Network Communications Group Co Ltd filed Critical China United Network Communications Group Co Ltd
Priority to CN201910362089.9A priority Critical patent/CN110134889B/en
Publication of CN110134889A publication Critical patent/CN110134889A/en
Application granted granted Critical
Publication of CN110134889B publication Critical patent/CN110134889B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

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/9566URL specific, e.g. using aliases, detecting broken or misspelled links

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 Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本发明提供一种短链接生成方法、装置及服务器,该方法包括:根据服务器的标识确定待转换长链接对应的第一字符串;为待转换长链接分配对应的第二字符串;待转换长链接对应的第二字符串与服务器中的其他长链接对应的第二字符串不同;根据待转换长链接对应的域名、第一字符串及第二字符串,生成待转换长链接对应的短链接。本发明提供的短链接生成方法、装置及服务器,可根据第一字符串和第二字符串共同确定待转换长链接所对应的短链接,由于第一字符串和第二字符串的组合唯一,因此,可保证待转换长链接所对应的短链接的唯一性。

Figure 201910362089

The present invention provides a method, device and server for generating a short link. The method includes: determining a first character string corresponding to a long link to be converted according to an identifier of the server; assigning a corresponding second character string to the long link to be converted; The second string corresponding to the link is different from the second string corresponding to other long links in the server; according to the domain name, the first string and the second string corresponding to the long link to be converted, a short link corresponding to the long link to be converted is generated . The short link generation method, device and server provided by the present invention can jointly determine the short link corresponding to the long link to be converted according to the first character string and the second character string. Since the combination of the first character string and the second character string is unique, Therefore, the uniqueness of the short link corresponding to the long link to be converted can be guaranteed.

Figure 201910362089

Description

Short link generation method and device and server
Technical Field
The present invention relates to communications technologies, and in particular, to a short link generation method, an apparatus, and a server.
Background
Various contents in the internet application have corresponding links, and a user can access the corresponding contents through the links. When the content provider pushes the link to the user, the link can be written in the short message and pushed to the user in a short message mode, and the short message sharing link can be sent between the users through the terminal.
Taking the terminal as a mobile phone as an example, since the length of the short message of the mobile phone is limited, when the link is a long link containing more characters, the information received by the user may not be complete or split into two short messages, thereby affecting the user to access the link. Therefore, it is usually necessary to convert the long links into short links containing fewer characters, and to push the short links to the user in the short message.
In the prior art, a long link is usually switched to a short link by adopting a hash algorithm, but the hash algorithm has collision, so that the switched short link has no uniqueness, that is, different long links may be switched to the same short link, thereby causing access abnormality when a user accesses through the short link.
Disclosure of Invention
The invention provides a short link generation method, a short link generation device and a short link generation server, which enable a converted short link to have uniqueness when a long link is converted into a short link, thereby improving the accuracy of access.
The invention provides a short link generation method, which is applied to a server and comprises the following steps:
determining a first character string corresponding to the long chain connection to be converted according to the identification of the server;
distributing a corresponding second character string for the long chain connection to be converted; the second character string corresponding to the long chain connection to be converted is different from the second character string corresponding to other long chains in the server;
and generating a short chain connection corresponding to the long chain connection to be converted according to the domain name corresponding to the long chain connection to be converted, the first character string and the second character string.
Optionally, the determining, according to the identifier of the server, a first character string corresponding to the long link to be converted includes:
acquiring the identifier of the server from a database cluster;
and shortening the identifier of the server to obtain a first character string corresponding to the long chain connection to be converted.
Optionally, the allocating a corresponding second character string for the long link to be converted includes:
acquiring a preset character; the preset character is a sequence value of the server for processing the long link to be converted, or the preset character is a random value distributed by the server for the long link to be converted;
and shortening the preset character to obtain a second character string corresponding to the long chain to be converted.
Optionally, the generating a short link corresponding to the long link to be converted according to the domain name corresponding to the long link to be converted, the first character string and the second character string includes:
sequentially splicing the domain name, the first character string and the second character string to obtain a first splicing result;
and determining the first splicing result as a short link corresponding to the long link to be converted.
Optionally, the generating a short link corresponding to the long link to be converted according to the domain name corresponding to the long link to be converted, the first character string and the second character string includes:
sequentially splicing the domain name, the second character string and the first character string to obtain a second splicing result;
and determining the second splicing result as a short link corresponding to the long link to be converted.
Optionally, the generating a short link corresponding to the long link to be converted according to the domain name corresponding to the long link to be converted, the first character string and the second character string includes:
calculating a third character string corresponding to the long chain connection to be converted by adopting a message digest algorithm;
sequentially splicing the domain name, the first character string, the second character string and the third character string to obtain a third splicing result;
and determining the third splicing result as a short link corresponding to the long link to be converted.
Optionally, the method further includes:
and establishing and storing a mapping relation between the long chain connection to be converted and the corresponding short chain connection.
Optionally, the database cluster is a Redis cluster.
The invention provides a short link generation device, which comprises:
the determining module is used for determining a first character string corresponding to the long chain connection to be converted according to the identifier of the device;
the distribution module is used for distributing a corresponding second character string for the long chain connection to be converted; the second character string corresponding to the long chain connection to be converted is different from the second character string corresponding to other long chain connections in the device;
and the generating module is used for generating a short link corresponding to the long link to be converted according to the domain name corresponding to the long link to be converted, the first character string and the second character string.
Optionally, the determining module is specifically configured to:
obtaining an identification of the device from a database cluster; and the mark of the device is shortened to obtain a first character string corresponding to the long chain connection to be converted. Optionally, the database cluster is a Redis cluster.
Optionally, the allocation module is specifically configured to:
acquiring a preset character; the preset character is a sequence value of the device for processing the long link to be converted, or the preset character is a random value distributed by the device for the long link to be converted; and shortening the preset character to obtain a second character string corresponding to the long chain to be converted.
Optionally, the generating module is specifically configured to:
sequentially splicing the domain name, the first character string and the second character string to obtain a first splicing result; and determining the first splicing result as a short link corresponding to the long link to be converted.
Optionally, the generating module is specifically configured to:
sequentially splicing the domain name, the second character string and the first character string to obtain a second splicing result; and determining the second splicing result as a short link corresponding to the long link to be converted.
Optionally, the generating module is specifically configured to:
calculating a third character string corresponding to the long chain connection to be converted by adopting a message digest algorithm; sequentially splicing the domain name, the first character string, the second character string and the third character string to obtain a third splicing result; and determining the third splicing result as a short link corresponding to the long link to be converted.
Optionally, the apparatus further comprises:
and the storage module is used for establishing and storing the mapping relation between the long link to be converted and the corresponding short link.
The invention provides a server, which is characterized by comprising a memory and a processor; the memory is connected with the processor;
the memory is used for storing a computer program;
the processor is configured to implement the short link generation method as described in any one of the above when the computer program is executed.
The invention provides a storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements a short link generation method as defined in any one of the above.
The invention provides a short link generation method, a short link generation device and a server.A first character string corresponding to a long link to be converted is determined according to an identifier of the server; and distributing a corresponding second character string for the long chain connection to be converted; the second character string corresponding to the long chain connection to be converted is different from the second character string corresponding to other long chain connections in the server; and generating a short chain connection corresponding to the long chain connection to be converted according to the domain name, the first character string and the second character string corresponding to the long chain connection to be converted. Therefore, when the short link corresponding to the long link to be converted is generated, the short link corresponding to the long link to be converted can be determined according to the first character string and the second character string, and the uniqueness of the short link corresponding to the long link to be converted can be ensured due to the unique combination of the first character string and the second character string, so that the accuracy of access is improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
FIG. 1 is a schematic flow diagram of a short chain-link generation method according to the present invention;
FIG. 2 is a schematic structural diagram of a short link generator according to the present invention;
fig. 3 is a schematic structural diagram of a server according to the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
FIG. 1 is a schematic flow diagram of a short chain joint generation method provided by the present invention. The execution subject of the method is a server, and the server can be realized by software and/or hardware. As shown in fig. 1, the method of this embodiment may include:
s101, determining a first character string corresponding to the long chain connection to be converted according to the identification of the server.
It will be appreciated that the identity of the server is unique. For example, the identifier of the server may be an identifier set before the server leaves a factory, or may be an identifier allocated to the server when the server is used, as long as the server can be uniquely identified.
In this embodiment, the server has an external interface to provide a service for converting a long link into a short link, and the user can send a request to the server by calling the interface, where the request includes the long link to be converted. After receiving the request, the server firstly determines a first character string corresponding to the long link to be converted according to the identifier of the server, wherein the identifier of the server is the unique identifier of the server.
At present, systems such as internet application and the like mostly adopt a distributed architecture, a plurality of servers can provide services in one application system, for example, a service for converting a long link into a short link can be provided by a plurality of servers, the number of the servers can be dynamically changed, namely, dynamic expansion or contraction, and each server has different server identifications. When the user calls the interface to use the service of converting the long link into the short link, the request sent by the user is distributed to one of the servers, and the first character string generated by the server according to the identification of the server can be used for distinguishing the server from other servers in the plurality of servers.
When a server processes a plurality of long links, if the first character strings corresponding to the long links are determined only according to the identification of the server, the first character strings corresponding to the long links are the same, and at this time, the uniqueness of the short links corresponding to the long links cannot be guaranteed, so that the short links corresponding to the long links need to be determined together with the second character strings, that is, the following steps S102 to S103 are executed:
and S102, distributing a corresponding second character string for the long chain connection to be converted.
And the second character string corresponding to the long link to be converted is different from the second character string corresponding to other long links in the server.
In the above S101, the server may be distinguished from other servers in the plurality of servers by the first character string, on this basis, in order to ensure uniqueness of the short link corresponding to the long link to be converted, a second character string needs to be further determined, and since the second character string corresponding to the long link to be converted is different from the second character strings corresponding to other long links in the server, the short link corresponding to the long link to be converted may be distinguished from the short links corresponding to other long links in the server by the second character string, thereby ensuring uniqueness of the short link corresponding to the long link to be converted.
S103, generating a short chain connection corresponding to the long chain connection to be converted according to the domain name, the first character string and the second character string corresponding to the long chain connection to be converted.
The long link to be converted consists of a domain name and a long string of characters, the domain name is taken out, and a short link corresponding to the long link to be converted is generated according to the domain name, the first character string and the first character string. The server can be distinguished from other servers in the servers by the first character string, and the second character string corresponding to the long chain connection to be converted is different from the second character strings corresponding to other long chain connections in the server, so that the short chain connection corresponding to the long chain connection to be converted is distinguished from the short chain connection corresponding to other long chain connections in the server by the second character string, and the uniqueness of the short chain connection corresponding to the long chain connection to be converted is ensured.
In the short link generation method provided by this embodiment, a first character string corresponding to a long link to be converted is determined according to an identifier of a server; and distributing a corresponding second character string for the long chain connection to be converted; the second character string corresponding to the long chain connection to be converted is different from the second character string corresponding to other long chain connections in the server; and generating a short chain connection corresponding to the long chain connection to be converted according to the domain name, the first character string and the second character string corresponding to the long chain connection to be converted. Therefore, when the short link corresponding to the long link to be converted is generated, the short link corresponding to the long link to be converted can be determined according to the first character string and the second character string, and the uniqueness of the short link corresponding to the long link to be converted can be ensured due to the unique combination of the first character string and the second character string, so that the accuracy of access is improved.
Based on the embodiment shown in fig. 1, when determining the first character string corresponding to the long link to be converted according to the identifier of the server in S101, the determining may include:
acquiring an identifier of a server from a database cluster; and shortening the identifier of the server to obtain a first character string corresponding to the long chain connection to be converted.
In this embodiment, the identifier of the server may be stored in a database cluster connected to the servers, that is, the database cluster allocates a corresponding server identifier to each server, so as to ensure that each server has a unique identifier, and when the number of servers increases, the database may automatically allocate an identifier to the newly added server. Alternatively, the database may be a Key-Value (Key-Value) type database, such as Redis, or may be a database in other forms, which is not specifically limited in the present invention. The server can perform data preloading when being started, and acquire a corresponding server identifier from the database cluster. In this way, when the server performs conversion of the long link, the first character string can be generated according to the server identifier acquired from the database in advance.
Further, a character set may be preset in the server, for example, the character set may include 62 characters from a to Z, a to z and from 0 to 9, and the character set is used to shorten the identifier of the server. Taking the character set of 62 characters as an example, arranging the 62 characters in sequence, dividing the identifier of the server by 62, replacing the quotient and the remainder in the obtained result with the characters in the corresponding sequence in the character set respectively, if the quotient is greater than 62, continuing dividing by 62, replacing the quotient and the remainder with the characters in the corresponding sequence in the character set respectively until the quotient is less than 62, and obtaining the first character string. And the identifier of the server is shortened by adopting the character set, so that the obtained first character string is shorter, and the short chain length corresponding to the long chain connection to be converted is shorter.
After the identifier of the server is shortened to obtain the first character string corresponding to the long link to be converted, in order to ensure the uniqueness of the short link, a corresponding second character string needs to be allocated to the long link to be converted, and S102 allocates a corresponding second character string to the long link to be converted, which may include:
acquiring a preset character string; the preset character string is a sequence value of the server for processing the long link to be converted, or the preset character string is a random value distributed by the server for the long link to be converted; and shortening the preset character string to obtain a second character string corresponding to the long chain to be converted.
In this embodiment, the preset character strings obtained by the server when performing long link conversion each time are different, and the preset character strings may be numerical values that sequentially increase according to the order of processing the long links to be converted, for example, a value of the preset character string increases by one or two or the preset character string may be a preset memory value in the server when processing the long links to be converted each time, and the server performs a self-increment calculation on the preset memory value each time performing long link conversion, thereby ensuring that the values obtained each time are different; the preset character string can also be an assigned random value, and the random value assigned by the server every time is different. And then, shortening the preset character string to obtain a second character string corresponding to the long chain to be converted. The method for shortening the preset character string is the same as the method for using the character set in the above embodiment, and details are not repeated here. And the preset character string is shortened by adopting the character set, so that the obtained second character string is shorter, and the short chain length corresponding to the long chain connection to be converted is shorter. The initial value of the preset character string can be set according to actual needs, so that the length of the second character string obtained when long link conversion is carried out each time is the same.
After the first character string and the second character string corresponding to the long chain connection to be converted are obtained, S103 may be executed to generate the short chain connection corresponding to the long chain connection to be converted according to the domain name, the first character string and the second character string corresponding to the long chain connection to be converted. For example, when the short link corresponding to the long link to be converted is generated according to the domain name corresponding to the long link to be converted, the first character string and the second character string, at least three possible implementation manners may be included, and the three possible implementation manners will be described in detail below.
In one possible implementation mode, sequentially splicing the domain name, the first character string and the second character string to obtain a first splicing result; and determining the first splicing result as a short link corresponding to the long link to be converted.
In another possible implementation manner, the domain name, the second character string and the first character string are spliced in sequence to obtain a second splicing result; and determining the second splicing result as a short link corresponding to the long link to be converted.
In the two possible implementation manners, the first character string is obtained according to the identifier of the server, so that the first character string can distinguish one server from other servers, meanwhile, the second character strings determined on one server are different, so that the first character string and the second character string are spliced to determine the only one character string in the multiple servers, the domain name, the first character string and the second character string are spliced to obtain the short link corresponding to the long link to be converted, and the uniqueness of the short link can be ensured.
In another possible implementation manner, a Message Digest (MD) algorithm is used to calculate a third string corresponding to the long chain to be converted; sequentially splicing the domain name, the first character string, the second character string and the third character string to obtain a third splicing result; and determining the third splicing result as a short link corresponding to the long link to be converted.
In practical application, a fifth version of the MD algorithm, that is, the MD5 algorithm, may be used to encrypt the long link to be converted to obtain 32-bit numbers, and the 32-bit numbers are segmented according to the length 8 to obtain 4 sets of data. The 16-ary number of each set of data performs a bitwise AND operation on 0x3FFFFFFF, with low 30-bit digital fidelity. The 30-bit data is cycled for 6 times, each cycle is shifted to the right by 5 bits, the 5 bits shifted to the right are scaled down by 62 bits through a 0x0000003D bitwise AND operation, and the 6-bit scaled-down number is obtained after 6 cycles. Each set of data is processed separately to obtain 4 sets of 6-bit reduced numbers, and any one of the 4 sets of 6-bit reduced numbers can be selected as the third string, and preferably, the first set of reduced numbers can be selected as the third string.
And sequentially splicing the domain name, the first character string, the second character string and the third character string to obtain a splicing result, namely the short link corresponding to the long link to be converted. Optionally, when the domain name, the first character string, the second character string, and the third character string are spliced, different splicing orders may be adopted for the first character string, the second character string, and the third character string, which is not limited in this invention.
Illustratively, if the long link to be converted is: https:// cc.xxxxx.com/kc/base/html/app _ open/detail-sendmsg. htmlklid. 1812140017540050748& isPublished. 1& isBackStage. 0& reginId. 97& ismissing. splitlld. 1812140017180050719& channelCode. CHNL 00000001. the domain name in the long link to be converted is cc.xxxxx.com. the first string determined using the method of this embodiment is q8, the second string is gLA9q, and the third string is bQrAzm. And taking the result https:// cc. xxxxx. com/s/q8gLA9qbQrAzm of the sequential splicing of the domain name, the first character string, the second character string and the third character string as the short link corresponding to the long link to be converted, wherein the sequential result of the first character string, the second character string and the third character string can be called as a short link code, namely q8gLA9qbQrAzm is a short link code.
In this embodiment, a third character string corresponding to the long chain connection to be converted is calculated by using an MD5 algorithm, and the domain name, the first character string, the second character string, and the third character string are spliced into a short chain connection corresponding to the long chain connection to be converted. In the method, if the first character string obtained by the server is abnormal, for example, when the server obtains the identifier of the server from the database cluster, the identifier obtained by the server is abnormal due to the database abnormality, for example, the identifier is empty, only the first character string and the second character string cannot uniquely identify a short link corresponding to a long link to be converted, and therefore, the short link corresponding to the long link to be converted is distinguished by adding the third character string, and high availability of the service is ensured.
In another embodiment, the short link generation method provided by the present invention further comprises: and establishing and storing a mapping relation between the long chain connection to be converted and the corresponding short chain connection. Therefore, when the user accesses through the short link, the long link corresponding to the short link can be directly obtained from the mapping relation, and then the content corresponding to the long link is accessed, so that the accessing efficiency is improved.
The following exemplifies a usage scenario of the short link generation method provided by the present invention in conjunction with practical applications.
In practical applications, after the long link is converted into the short link, the user can access the short link. Two services can thus be designed: the system comprises a front-end service and a back-end service, wherein the front-end service receives a request for converting a long link into a long link and skips the long link, and the back-end service provides a service for converting the long link into a short link and a service for converting the short link into the long link.
For example, when the connection needs to be released to the user by sending the short message, the long-link switching short-link service is firstly called through the interface, the short link corresponding to the long link is obtained, and the obtained short link is added into the short message template and sent to the user.
When a user accesses corresponding content through a short link in a received short message, in order to ensure that the same response is required when the user accesses different short links, a reverse proxy is used for intercepting related paths and reversely acting the related paths to the same inlet, a short link switching long link service is called when an inlet page is loaded, a long link address is obtained, and the long link address is requested in a page redirection mode.
Fig. 2 is a schematic structural diagram of a short link generation device provided by the present invention. As shown in fig. 2, the short link generation device 20 includes:
the determining module 201 is configured to determine, according to the identifier of the short link generating device 20, a first character string corresponding to the long link to be converted.
The distribution module 202 is configured to distribute a corresponding second character string to the long link to be converted; the second character string corresponding to the long chain link to be converted is different from the second character string corresponding to the other long chain links in the short chain link generation device 20.
The generating module 203 is configured to generate a short link corresponding to the long link to be converted according to the domain name corresponding to the long link to be converted, the first character string, and the second character string.
Optionally, the determining module 201 is specifically configured to:
obtaining an identification of the short link generator 20 from the database cluster; and shortening the mark of the short link generation device 20 to obtain a first character string corresponding to the long link to be converted. Optionally, the database cluster is a Redis cluster.
Optionally, the allocating module 202 is specifically configured to:
acquiring a preset character; the preset character is a sequence value of the short link generation device 20 for processing the long link to be converted, or the preset character is a random value allocated by the short link generation device 20 for the long link to be converted; and shortening the preset character to obtain a second character string corresponding to the long chain to be converted.
Optionally, the generating module 203 is specifically configured to:
sequentially splicing the domain name, the first character string and the second character string to obtain a first splicing result; and determining the first splicing result as a short link corresponding to the long link to be converted.
Optionally, the generating module 203 is specifically configured to:
sequentially splicing the domain name, the second character string and the first character string to obtain a second splicing result; and determining the second splicing result as a short link corresponding to the long link to be converted.
Optionally, the generating module 203 may be further specifically configured to:
calculating a third character string corresponding to the long chain connection to be converted by adopting a message digest algorithm; sequentially splicing the domain name, the first character string, the second character string and the third character string to obtain a third splicing result; and determining the third splicing result as a short link corresponding to the long link to be converted.
Optionally, the short link generation device 20 further includes:
the storage module 204 is configured to establish and store a mapping relationship between the long link to be converted and the corresponding short link.
The short link generation device provided by the embodiment is used for realizing the short link generation method in any embodiment, the realization principle and the technical effect are the same, and the details are not repeated here.
Fig. 3 is a schematic structural diagram of a server according to the present invention. As shown in fig. 3, the server 30 includes a memory 301 and a processor 302; the memory 301 is connected to the processor 302.
The memory 301 is used to store computer programs.
The processor 302 is configured to implement the short link generation method in any of the above embodiments when the computer program is executed.
The server provided by this embodiment is used to implement the short link generation method in any of the above embodiments, and the implementation principle and technical effect are the same, which are not described herein again.
The present invention provides a storage medium having stored thereon a computer program which, when executed by a processor, implements the short link generation method of any of the above embodiments.
Those of ordinary skill in the art will understand that: all or a portion of the steps of implementing the above-described method embodiments may be performed by hardware associated with program instructions. The program may be stored in a computer-readable storage medium. When executed, the program performs steps comprising the method embodiments described above; and the aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic or optical disks.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.

Claims (16)

1.一种短链接生成方法,其特征在于,应用于服务器,所述方法包括:1. a short link generation method, is characterized in that, is applied to server, and described method comprises: 根据所述服务器的标识确定待转换长链接对应的第一字符串;Determine the first character string corresponding to the long link to be converted according to the identifier of the server; 为所述待转换长链接分配对应的第二字符串;所述待转换长链接对应的第二字符串与所述服务器中的其他长链接对应的第二字符串不同;assigning a corresponding second character string to the long link to be converted; the second character string corresponding to the long link to be converted is different from the second character string corresponding to other long links in the server; 根据所述待转换长链接对应的域名、所述第一字符串及所述第二字符串,生成所述待转换长链接对应的短链接;generating a short link corresponding to the long link to be converted according to the domain name, the first character string and the second character string corresponding to the long link to be converted; 所述根据所述服务器的标识确定待转换长链接对应的第一字符串,包括:The determining of the first character string corresponding to the long link to be converted according to the identifier of the server includes: 所述服务器在启动时进行数据预加载,从数据库集群中获取所述服务器的标识;所述服务器的标识存储在与所述服务器连接的所述数据库集群中;The server performs data preloading when starting, and obtains the identifier of the server from the database cluster; the identifier of the server is stored in the database cluster connected to the server; 对所述服务器的标识进行缩短处理,得到所述待转换长链接对应的第一字符串。The identifier of the server is shortened to obtain the first character string corresponding to the long link to be converted. 2.根据权利要求1所述的方法,其特征在于,所述为所述待转换长链接分配对应的第二字符串,包括:2. The method according to claim 1, wherein the assigning a corresponding second character string to the long link to be converted comprises: 获取预设字符串;所述预设字符串为所述服务器处理所述待转换长链接的顺序值,或者,所述预设字符串为所述服务器为所述待转换长链接分配的随机值;Obtain a preset character string; the preset character string is the sequence value for processing the long link to be converted by the server, or the preset character string is a random value allocated by the server for the long link to be converted ; 对所述预设字符串进行缩短处理,得到所述待转换长链接对应的第二字符串。The preset character string is shortened to obtain a second character string corresponding to the long link to be converted. 3.根据权利要求1或2任一项所述的方法,其特征在于,所述根据所述待转换长链接对应的域名、所述第一字符串及所述第二字符串,生成所述待转换长链接对应的短链接,包括:3. The method according to any one of claims 1 or 2, wherein the generating the Short links corresponding to long links to be converted, including: 对所述域名、所述第一字符串及所述第二字符串依次拼接,得到第一拼接结果;Splicing the domain name, the first character string and the second character string in turn to obtain a first splicing result; 将所述第一拼接结果,确定为所述待转换长链接对应的短链接。The first splicing result is determined as a short link corresponding to the long link to be converted. 4.根据权利要求1或2任一项所述的方法,其特征在于,所述根据所述待转换长链接对应的域名、所述第一字符串及所述第二字符串,生成所述待转换长链接对应的短链接,包括:4. The method according to any one of claims 1 or 2, wherein the generating the Short links corresponding to long links to be converted, including: 对所述域名、所述第二字符串及所述第一字符串依次拼接,得到第二拼接结果;Splicing the domain name, the second character string and the first character string in turn to obtain a second splicing result; 将所述第二拼接结果,确定为所述待转换长链接对应的短链接。The second splicing result is determined as a short link corresponding to the long link to be converted. 5.根据权利要求1或2任一项所述的方法,其特征在于,所述根据所述待转换长链接对应的域名、所述第一字符串及所述第二字符串,生成所述待转换长链接对应的短链接,包括:5. The method according to any one of claims 1 or 2, wherein the generating the Short links corresponding to long links to be converted, including: 采用消息摘要算法计算所述待转换长链接对应的第三字符串;Calculate the third character string corresponding to the long link to be converted by adopting a message digest algorithm; 对所述域名、所述第一字符串、所述第二字符串及所述第三字符串依次拼接,得到第三拼接结果;Splicing the domain name, the first character string, the second character string and the third character string in turn to obtain a third splicing result; 将所述第三拼接结果,确定为所述待转换长链接对应的短链接。The third splicing result is determined as a short link corresponding to the long link to be converted. 6.根据权利要求1或2任一项所述的方法,其特征在于,所述方法还包括:6. The method according to any one of claims 1 or 2, wherein the method further comprises: 建立并存储所述待转换长链接与其对应的短链接之间的映射关系。A mapping relationship between the long link to be converted and its corresponding short link is established and stored. 7.根据权利要求1所述的方法,其特征在于,所述数据库集群为Redis集群。7. The method according to claim 1, wherein the database cluster is a Redis cluster. 8.一种短链接生成装置,其特征在于,包括:8. A device for generating short links, comprising: 确定模块,用于根据所述装置的标识确定待转换长链接对应的第一字符串;a determining module, configured to determine the first character string corresponding to the long link to be converted according to the identifier of the device; 分配模块,用于为所述待转换长链接分配对应的第二字符串;所述待转换长链接对应的第二字符串与所述装置中的其他长链接对应的第二字符串不同;an allocation module, configured to allocate a corresponding second character string for the long link to be converted; the second character string corresponding to the long link to be converted is different from the second character string corresponding to other long links in the device; 生成模块,用于根据所述待转换长链接对应的域名、所述第一字符串及所述第二字符串,生成所述待转换长链接对应的短链接;A generating module, configured to generate a short link corresponding to the long link to be converted according to the domain name, the first character string and the second character string corresponding to the long link to be converted; 所述确定模块具体用于:The determining module is specifically used for: 所述装置在启动时进行数据预加载,从数据库集群中获取所述装置的标识;所述装置的标识存储在与所述装置连接的所述数据库集群中;The device performs data preloading when it is started, and obtains the identifier of the device from the database cluster; the identifier of the device is stored in the database cluster connected to the device; 对所述装置的标识进行缩短处理,得到所述待转换长链接对应的第一字符串。The identification of the device is shortened to obtain the first character string corresponding to the long link to be converted. 9.根据权利要求8所述的装置,其特征在于,所述分配模块具体用于:9. The device according to claim 8, wherein the distribution module is specifically used for: 获取预设字符串;所述预设字符串为所述装置处理所述待转换长链接的顺序值,或者,所述预设字符串为所述装置为所述待转换长链接分配的随机值;Obtain a preset character string; the preset character string is a sequence value of the long link to be converted by the device, or the preset character string is a random value assigned by the device to the long link to be converted ; 对所述预设字符串进行缩短处理,得到所述待转换长链接对应的第二字符串。The preset character string is shortened to obtain a second character string corresponding to the long link to be converted. 10.根据权利要求8或9任一项所述的装置,其特征在于,所述生成模块具体用于:10. The device according to any one of claims 8 or 9, wherein the generating module is specifically used for: 对所述域名、所述第一字符串及所述第二字符串依次拼接,得到第一拼接结果;Splicing the domain name, the first character string and the second character string in turn to obtain a first splicing result; 将所述第一拼接结果,确定为所述待转换长链接对应的短链接。The first splicing result is determined as a short link corresponding to the long link to be converted. 11.根据权利要求8或9任一项所述的装置,其特征在于,所述生成模块具体用于:11. The apparatus according to any one of claims 8 or 9, wherein the generating module is specifically configured to: 对所述域名、所述第二字符串及所述第一字符串依次拼接,得到第二拼接结果;Splicing the domain name, the second character string and the first character string in turn to obtain a second splicing result; 将所述第二拼接结果,确定为所述待转换长链接对应的短链接。The second splicing result is determined as a short link corresponding to the long link to be converted. 12.根据权利要求8或9任一项所述的装置,其特征在于,所述生成模块具体用于:12. The device according to any one of claims 8 or 9, wherein the generating module is specifically configured to: 采用消息摘要算法计算所述待转换长链接对应的第三字符串;Calculate the third character string corresponding to the long link to be converted by adopting a message digest algorithm; 对所述域名、所述第一字符串、所述第二字符串及所述第三字符串依次拼接,得到第三拼接结果;Splicing the domain name, the first character string, the second character string and the third character string in turn to obtain a third splicing result; 将所述第三拼接结果,确定为所述待转换长链接对应的短链接。The third splicing result is determined as a short link corresponding to the long link to be converted. 13.根据权利要求8或9任一项所述的装置,其特征在于,所述装置还包括:13. The device according to any one of claims 8 or 9, wherein the device further comprises: 存储模块,用于建立并存储所述待转换长链接与其对应的短链接之间的映射关系。A storage module, configured to establish and store the mapping relationship between the long link to be converted and its corresponding short link. 14.根据权利要求8所述的装置,其特征在于,所述数据库集群为Redis集群。14. The apparatus according to claim 8, wherein the database cluster is a Redis cluster. 15.一种服务器,其特征在于,包括存储器及处理器;所述存储器与所述处理器连接;15. A server, comprising a memory and a processor; the memory is connected to the processor; 所述存储器,用于存储计算机程序;the memory for storing computer programs; 所述处理器,用于在计算机程序被执行时,实现如上述权利要求1-7中任一项所述的短链接生成方法。The processor is configured to implement the short link generation method according to any one of the preceding claims 1-7 when the computer program is executed. 16.一种存储介质,其上存储有计算机程序,其特征在于,所述计算机程序被处理器执行时,实现如上述权利要求1-7中任一项所述的短链接生成方法。16. A storage medium on which a computer program is stored, characterized in that, when the computer program is executed by a processor, the method for generating a short link according to any one of the preceding claims 1-7 is implemented.
CN201910362089.9A 2019-04-30 2019-04-30 Short link generation method and device and server Active CN110134889B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910362089.9A CN110134889B (en) 2019-04-30 2019-04-30 Short link generation method and device and server

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910362089.9A CN110134889B (en) 2019-04-30 2019-04-30 Short link generation method and device and server

Publications (2)

Publication Number Publication Date
CN110134889A CN110134889A (en) 2019-08-16
CN110134889B true CN110134889B (en) 2021-08-10

Family

ID=67575826

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910362089.9A Active CN110134889B (en) 2019-04-30 2019-04-30 Short link generation method and device and server

Country Status (1)

Country Link
CN (1) CN110134889B (en)

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110851748A (en) * 2019-10-14 2020-02-28 平安科技(深圳)有限公司 Short link generation method, server, storage medium and computer equipment
CN110968460B (en) * 2019-11-27 2020-10-27 上海众言网络科技有限公司 Method and device for recovering website in system breakdown state
CN111047413B (en) * 2019-12-17 2023-11-07 秒针信息技术有限公司 Method, device, computer equipment and readable storage medium for acquiring text content
CN111651695A (en) * 2020-05-29 2020-09-11 深圳前海微众银行股份有限公司 Method and device for generating and parsing short links
CN112035763A (en) * 2020-09-01 2020-12-04 中国银行股份有限公司 Information processing method, device and system, electronic equipment and storage medium
CN112861032A (en) * 2021-01-20 2021-05-28 银盛通信有限公司 Short link generation method and system
CN112883301A (en) * 2021-02-03 2021-06-01 叮当快药科技集团有限公司 Method and device for generating short link based on 55 system and storage medium
CN113420238A (en) * 2021-06-18 2021-09-21 浙江集享电子商务有限公司 Short link generation method, device, electronic device and storage medium
CN113505318A (en) * 2021-07-26 2021-10-15 全景智联(武汉)科技有限公司 Short link generation method, device, equipment and storage medium
CN113761406B (en) * 2021-09-03 2024-06-04 丰巢网络技术有限公司 Intelligent cabinet two-dimension code short-chain generation method and device, medium and electronic equipment
CN116028734B (en) * 2023-02-24 2025-05-02 阿维塔科技(重庆)有限公司 A short link generation method, device, equipment and computer-readable storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102984287A (en) * 2012-11-19 2013-03-20 青岛海信传媒网络技术有限公司 Microblog application server and microblog platform chained address sharing method thereof
CN104080059A (en) * 2013-03-25 2014-10-01 中国移动通信集团福建有限公司 Method, device and system of implementing short message sending and receiving
CN106210161A (en) * 2016-06-24 2016-12-07 中国银联股份有限公司 A kind of short chain delivers a child into method and system
CN106933854A (en) * 2015-12-30 2017-07-07 阿里巴巴集团控股有限公司 Short linking processing method, device and server
CN107729409A (en) * 2017-09-26 2018-02-23 中国银联股份有限公司 A kind of short chain delivers a child into method and device
CN107749861A (en) * 2017-11-16 2018-03-02 平安科技(深圳)有限公司 Information-pushing method, device, terminal device and storage medium

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101674374A (en) * 2009-09-02 2010-03-17 优视动景(北京)技术服务有限公司 Webpage content extraction forwarding system for mobile communication terminal and application method thereof
US20150095487A1 (en) * 2013-09-30 2015-04-02 Trksit, Llc Third-party link tracker system and method
CN104702677B (en) * 2015-02-13 2017-06-23 腾讯科技(深圳)有限公司 Linking processing method, device and system
CN106412140A (en) * 2015-08-03 2017-02-15 沈阳东软睿道教育服务有限公司 Short link address generating method and system thereof
CN106933871B (en) * 2015-12-30 2021-08-17 创新先进技术有限公司 Short link processing method, device and short link server
CN109582395B (en) * 2019-01-10 2022-05-17 北京三快在线科技有限公司 Mini program running method, device, electronic device and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102984287A (en) * 2012-11-19 2013-03-20 青岛海信传媒网络技术有限公司 Microblog application server and microblog platform chained address sharing method thereof
CN104080059A (en) * 2013-03-25 2014-10-01 中国移动通信集团福建有限公司 Method, device and system of implementing short message sending and receiving
CN106933854A (en) * 2015-12-30 2017-07-07 阿里巴巴集团控股有限公司 Short linking processing method, device and server
CN106210161A (en) * 2016-06-24 2016-12-07 中国银联股份有限公司 A kind of short chain delivers a child into method and system
CN107729409A (en) * 2017-09-26 2018-02-23 中国银联股份有限公司 A kind of short chain delivers a child into method and device
CN107749861A (en) * 2017-11-16 2018-03-02 平安科技(深圳)有限公司 Information-pushing method, device, terminal device and storage medium

Also Published As

Publication number Publication date
CN110134889A (en) 2019-08-16

Similar Documents

Publication Publication Date Title
CN110134889B (en) Short link generation method and device and server
CN107819828B (en) Data transmission method and device, computer equipment and storage medium
AU2019101559A4 (en) Method and apparatus for generating random character string
CN107733972A (en) A kind of short linking analytic method, device and equipment
CN109376172B (en) Data acquisition method and system based on block chain
CN109800236A (en) Support the distributed caching method and equipment of multinode
CN113032156A (en) Memory allocation method and device, electronic equipment and storage medium
CN111629063A (en) Block chain based distributed file downloading method and electronic equipment
CN105530311A (en) Load distribution method and device
CN112650710B (en) Sending method and device for data migration, storage medium, and electronic device
CN114244654A (en) URL forwarding method, device, equipment and computer storage medium
CN113612869A (en) Short network address generation method, terminal and storage medium
CN109471713B (en) Method and device for inquiring information
CN110334103B (en) Recommendation service updating method, providing device, access device and recommendation system
WO2013013477A1 (en) Data packet processing and tracing method, device and system
CN113179295B (en) Message processing method and device
CN107276998B (en) OpenSSL-based performance optimization method and device
CN105704207A (en) Method for generating unique identifier, terminal and network side
US20210073043A1 (en) Method and system for uniform, consistent, stateless and deterministic consistent hashing for fixed size partitions
CN116530071A (en) CAN address assignment
CN105979003A (en) File downloading method, device and system
CN111274017A (en) Resource processing method and device, electronic equipment and storage medium
CN117473176A (en) Short link generation method, device, equipment and storage medium
CN113922972B (en) Data forwarding method and device based on MD5 identification code
US20140047014A1 (en) Network access system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant