Long link restoration method and device, server and storage medium
The hash function quickly locates the long link position of the short link, reduces database queries, solves the problems of server resource occupation and inefficiency, and improves the efficiency of long link restoration.
Patent Information
- Application Number
- CN202310671832.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-07
- Publication Date
- 2024-12-10
AI Technical Summary
In the prior art, when the short link restores a long link, the database resources on the server are invalidly occupied, and pressure on the database is put on the high request volume, resulting in inefficiency.
By presetting multiple hash functions, it hash calculations for short links to be processed, and quickly locate their target position in the bit array. If the value of the target position is the preset value, it is considered that the long link exists. Query it in the cache first to avoid Invalid database query, reducing resource consumption.
It effectively reduces the ineffective resource occupation and query pressure of the database, improves the efficiency of the server in large data scenarios, quickly locates whether long links exist, and reduces the frequency of database access.
Smart Images

Figure CN119106208A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of Internet technology, and in particular to a long link restoration method, device, server and storage medium. Background Art
[0002] The scenario of short link restoring long link is: after generating a short link based on the long link (usually a longer real promotional link), the short link is sent to the user via SMS, email, in-site message, etc. After the user clicks the short link, the server restores the short link to the long link, and the user's browser is redirected to the web page corresponding to the long link.
[0003] In the prior art, after a user clicks on a short link, the server will query the identifier between the short link and the long link in the database to obtain the long link address, and then return it to the browser for address redirection so that the user can access the corresponding web page.
[0004] However, in the prior art, some short links do not have corresponding long links, and accessing through a database will cause the resources of the database in the server to be ineffectively occupied. Summary of the invention
[0005] The present application provides a long link restoration method, device, server and storage medium to solve the problem of invalid occupation of database resources in the server in the long link restoration scenario in the prior art.
[0006] In a first aspect, the present application provides a long link restoration method, comprising:
[0007] Get the short link to be processed;
[0008] Determine the target position of the short link to be processed in a preset bit array according to the preset multiple hash functions and the short link to be processed;
[0009] If the target position and the value at the same position in at least one first bit array are both preset values, it is determined that the long link corresponding to the short link to be processed exists, and the first bit array is a bit array in which the preset value is filled in the corresponding position of the bit array for the short link pre-determined in the cache;
[0010] According to the short link to be processed, a long link corresponding to the short link to be processed is determined in a database.
[0011] In a possible design of the first aspect, determining a target position of the short link to be processed in a preset bit array according to the preset multiple hash functions and the short link to be processed includes:
[0012] Using the multiple hash functions to perform hash calculations on the short links to be processed to obtain multiple target hash values;
[0013] The target position of the short link to be processed in the bit array is obtained by performing modulo operation on the integer index values corresponding to the multiple target hash values and the length of the bit array.
[0014] In another possible design of the first aspect, if the target position and the value at the same position in at least one first bit array are both preset values, after determining that a long link corresponding to the short link to be processed exists, the method further includes:
[0015] Querying the cache whether a long link corresponding to the short link to be processed exists;
[0016] If the cache contains a long link corresponding to the short link to be processed, returning page data corresponding to the long link to the user, so that the user's terminal device renders the page corresponding to the long link;
[0017] If the long link corresponding to the short link to be processed does not exist in the cache, the long link determined in the database is backfilled into the cache.
[0018] Optionally, the method further includes:
[0019] If the long link corresponding to the short link to be processed does not exist in the database, an error reminder is returned to the user, where the error reminder is used to prompt the user that the page of the long link corresponding to the short link to be processed does not exist.
[0020] In another possible design of the first aspect, after determining the target position of the short link to be processed in a preset bit array according to the preset multiple hash functions and the short link to be processed, the method further includes:
[0021] If the target position does not have a preset value as the value at the same position in at least one first position array, an error reminder is returned to the user, and the error reminder is used to prompt the user that the page of the long link corresponding to the short link to be processed does not exist.
[0022] In yet another possible design of the first aspect, before determining that a long link corresponding to the short link to be processed exists if the values at the target positions are all preset values, the method further includes:
[0023] Obtaining the multiple short links;
[0024] For each short link, use the multiple hash functions to perform hash calculation on the short link to be processed to obtain multiple hash values;
[0025] Obtaining the position of the short link in the bit array by performing modulo operation on the integer index values corresponding to the multiple hash values and the length of the bit array;
[0026] The value corresponding to the position of the short link in the bit array is filled with the preset value to obtain the first bit array.
[0027] In yet another possible design of the first aspect, the method further includes:
[0028] The page data corresponding to the long link is returned to the user so that the user's terminal device renders the page corresponding to the long link.
[0029] In a second aspect, the present application provides a long link restoration device, comprising:
[0030] The acquisition module is used to obtain the short link to be processed;
[0031] A first determination module, configured to determine a target position of the short link to be processed in a preset bit array according to a plurality of preset hash functions and the short link to be processed;
[0032] A second determination module is configured to determine that a long link corresponding to the short link to be processed exists if the target position and the value at the same position in at least one first bit array are both preset values, and the first bit array is a bit array in which the short link pre-determined in the cache is filled with the preset value at the corresponding position in the bit array;
[0033] The third determining module is used to determine the long link corresponding to the short link to be processed in the database according to the short link to be processed.
[0034] In a possible design of the second aspect, the first determining module is specifically configured to:
[0035] Using the multiple hash functions to perform hash calculations on the short links to be processed to obtain multiple target hash values;
[0036] The target position of the short link to be processed in the bit array is obtained by performing modulo operation on the integer index values corresponding to the multiple target hash values and the length of the bit array.
[0037] In another possible design of the second aspect, if the target position and the value at the same position in at least one first position array are both preset values, after determining that the long link corresponding to the short link to be processed exists, the second determination module is further used to:
[0038] Querying the cache whether a long link corresponding to the short link to be processed exists;
[0039] If the cache contains a long link corresponding to the short link to be processed, returning page data corresponding to the long link to the user, so that the user's terminal device renders the page corresponding to the long link;
[0040] If the long link corresponding to the short link to be processed does not exist in the cache, the long link determined in the database is backfilled into the cache.
[0041] Optionally, returns a module for:
[0042] If the long link corresponding to the short link to be processed does not exist in the database, an error reminder is returned to the user, where the error reminder is used to prompt the user that the page of the long link corresponding to the short link to be processed does not exist.
[0043] In another possible design of the second aspect, after determining the target position of the short link to be processed in a preset bit array according to the preset multiple hash functions and the short link to be processed, the returning module is further used to:
[0044] If the target position does not have a preset value as the value at the same position in at least one first position array, an error reminder is returned to the user, and the error reminder is used to prompt the user that the page of the long link corresponding to the short link to be processed does not exist.
[0045] In yet another possible design of the second aspect, if the values at the target positions are all preset values, before determining that a long link corresponding to the short link to be processed exists, the acquisition module is further used to:
[0046] Obtaining the multiple short links;
[0047] For each short link, use the multiple hash functions to perform hash calculation on the short link to be processed to obtain multiple hash values;
[0048] Obtaining the position of the short link in the bit array by performing modulo operation on the integer index values corresponding to the multiple hash values and the length of the bit array;
[0049] The value corresponding to the position of the short link in the bit array is filled with the preset value to obtain the first bit array.
[0050] In yet another possible design of the second aspect, the return module is further used to:
[0051] The page data corresponding to the long link is returned to the user so that the user's terminal device renders the page corresponding to the long link.
[0052] In a third aspect, the present application provides a server, comprising: a processor, and a memory and a transceiver communicatively connected to the processor;
[0053] The memory stores computer-executable instructions; the transceiver is used to send and receive data;
[0054] The processor executes the computer-executable instructions stored in the memory to implement the method as described in the first aspect or any one of the above methods.
[0055] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the method described in the first aspect or any one of the above methods.
[0056] The long link restoration method, device, server and storage medium provided by the present application obtain the short link to be processed, and determine the target position of the short link to be processed in the preset bit array according to the preset multiple hash functions and the short link to be processed. If the target position and the value at the same position in at least one first bit array are both preset values, it is determined that the long link corresponding to the short link to be processed exists. The first bit array is a bit array filled with preset values at the corresponding position of the short link determined in advance in the cache. Finally, according to the short link to be processed, the long link corresponding to the short link to be processed is determined in the database. In this technical solution, firstly, it is quickly located whether the long link corresponding to the short link to be processed exists, thereby reducing unnecessary resource consumption of the database and improving the efficiency of the server in large data volume scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0058] Figure 1 Schematic diagram of the long link restoration method provided in the embodiment of the present application Figure 1 ;
[0059] Figure 2 Schematic diagram of the long link restoration method provided in the embodiment of the present application Figure 2 ;
[0060] Figure 3 Schematic diagram of the long link restoration method provided in the embodiment of the present application Figure 3 ;
[0061] Figure 4 Schematic diagram of the long link restoration method provided in the embodiment of the present application Figure 4 ;
[0062] Figure 5 Schematic diagram of the long link restoration method provided in the embodiment of the present application Figure 5 ;
[0063] Figure 6 A schematic diagram of the structure of a long link restoration device provided in an embodiment of the present application;
[0064] Figure 7 A schematic diagram of the structure of a server provided in an embodiment of the present application.
[0065] The above drawings show clear embodiments of the present disclosure, which will be described in more detail below. These drawings and text descriptions are not intended to limit the scope of the present disclosure in any way, but to illustrate the concepts of the present disclosure to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0066] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0067] Before introducing the embodiments of the present application, the application background of the embodiments of the present application is first explained:
[0068] The scenario of short link restoring long link is: after generating a short link based on the long link (usually a longer real promotional link), the short link is sent to the user via SMS, email, in-site message, etc. After the user clicks the short link, the server restores the short link to the long link, and the user's browser is redirected to the web page corresponding to the long link.
[0069] In the prior art, after a user clicks on a short link, the server will query the identifier between the short link and the long link in the database to obtain the long link address, and then return it to the browser for address redirection so that the user can access the corresponding web page.
[0070] The problems existing in the prior art that need to be solved by the embodiments of the present application are:
[0071] 1. Some short links do not have corresponding long links, and accessing them through the database will cause the database resources on the server to be invalidly occupied;
[0072] 2. To restore an existing short link to a long link, you need to query the database. When the number of requests is large, it will put pressure on the database.
[0073] In view of the technical problems existing in the prior art, the inventor of the present application has the following idea: in order to reduce the invalid occupation of database resources, after the server receives the request for the short link, it can pre-judge whether the short link exists with a corresponding long link. If so, the database access operation can be performed. The judgment of whether the short link exists with a long link can be implemented by means of a hash function, that is, the short link is compressed into the form of a bit array. Before determination, all short links are marked with relevant bit arrays, thereby achieving the effect of pre-judgment, avoiding idle queries of non-existent caches in the database, and quickly restoring the short link to the long link.
[0074] The technical solution of the present application is described in detail below through specific embodiments. It should be noted that the following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
[0075] It is worth noting that the application fields of the long link restoration method, device, server and storage medium disclosed in the present invention are not limited.
[0076] Among them, the executor of this application is the server, which can be the server corresponding to the short link.
[0077] Figure 1 Schematic diagram of the long link restoration method provided in the embodiment of the present application Figure 1 ,like Figure 1 As shown, the long link restoration method may include the following steps:
[0078] Step 11: Get the short link to be processed;
[0079] In this step, the server obtains the short link sent by the terminal device, that is, the short link to be processed.
[0080] In one possible implementation, the short link to be processed can be a short link corresponding to a promotional link, which is sent to the user via SMS, email, in-site message, etc. When the user clicks the short link in the terminal device, the server responds to the click and obtains the short link.
[0081] Step 12: Determine the target position of the short link to be processed in the preset bit array according to the preset multiple hash functions and the short link to be processed;
[0082] In this step, multiple hash functions are used to process the short link to be processed, and after the processing, the bit array position corresponding to the short link to be processed, that is, the target position, is determined in a preset bit array.
[0083] The detailed implementation of this step is given in the following embodiment.
[0084] Step 13: If the target position and the value at the same position in at least one first position array are both preset values, it is determined that a long link corresponding to the short link to be processed exists.
[0085] The first bit array is a bit array in which a preset value is filled in a corresponding position in the bit array of a short link determined in advance in the cache;
[0086] In this step, since a plurality of determined short links are stored in the cache in advance and the bit arrays in which the corresponding positions in the bit array are filled with preset values, that is, the first bit array corresponding to each short link, at this time, it is determined whether there is a first bit array at the target position corresponding to the short link to be processed and the values at the same position in the first bit array are all preset values. If there is a first bit array that meets the requirements, it is determined that the long link corresponding to the short link to be processed exists.
[0087] In one possible implementation, the target positions of the short link to be processed in the preset bit array are the 1st, 3rd, 11th, and 12th bits; a bit array with preset values filled in the corresponding positions of multiple short links in the bit array is stored in the cache. At this time, if a bit array in which the 1st, 3rd, 11th, and 12th bits are all preset values can be determined, it is determined that the long link corresponding to the short link to be processed exists.
[0088] Optionally, the preset value may be 1.
[0089] Optionally, before step 13, at least one first bit array may be determined, and the corresponding implementation process is as follows:
[0090] Step 1. Get multiple short links;
[0091] It should be understood that each of the multiple short links corresponds to a corresponding long link.
[0092] Step 2: For each short link, use multiple hash functions to perform hash calculations on the short link to be processed to obtain multiple hash values;
[0093] For each short link, the following processing is performed: first, multiple different hash functions are determined, and each hash function is used to perform hash calculations on the short link to obtain a hash value corresponding to each hash function.
[0094] Step 3: Take the modulus of the integer index values corresponding to the multiple hash values and the length of the bit array to obtain the position of the short link in the bit array;
[0095] For each hash value, first determine its inter value, that is, calculate the integer index value corresponding to each hash value.
[0096] Then, the modulus of each integer index value and the length of the bit array is taken, and the obtained remainder is used as the position of the short link in the bit array, that is, the remainder corresponding to each integer index value is used as the position of the short link in the bit array.
[0097] The length of the bit array is related to the short link.
[0098] Step 4: Fill the value corresponding to the position of the short link in the bit array with the preset value to obtain the first bit array.
[0099] The value corresponding to the position of the short link in the bit array determined above is filled with a preset value to obtain the first bit array corresponding to the short link.
[0100] Among them, the preset value can be 1.
[0101] After step 12, if the target position does not have a preset value as the value at the same position in at least one first position array, an error reminder is returned to the user, and the error reminder is used to prompt the user that the page of the long link corresponding to the short link to be processed does not exist.
[0102] That is, in each first bit array, determine the position that is the same as the target position, and determine whether it is a preset value at the same position. If no values at the same position in a bit array are all preset values, it is determined that the long link corresponding to the short link to be processed does not exist, and an error reminder is returned to the user.
[0103] Among them, the error reminder can be a reminder message sent by the server to the terminal device, and the page displayed on the terminal device side is 404.
[0104] Step 14: According to the short link to be processed, the long link corresponding to the short link to be processed is determined in the database.
[0105] In this step, when it is preliminarily determined that a long link corresponding to the short link to be processed exists, the long link corresponding to the identifier is determined in the database based on the identifier of the short link to be processed.
[0106] Furthermore, the page data corresponding to the long link is returned to the user so that the user's terminal device renders the page corresponding to the long link.
[0107] The long link restoration method provided in the embodiment of the present application obtains the short link to be processed, and determines the target position of the short link to be processed in the preset bit array according to the preset multiple hash functions and the short link to be processed. If the target position and the value at the same position in at least one first bit array are both preset values, it is determined that the long link corresponding to the short link to be processed exists. The first bit array is a bit array filled with preset values at the corresponding position in the bit array of the short link pre-determined in the cache. Finally, according to the short link to be processed, the long link corresponding to the short link to be processed is determined in the database. In this technical solution, firstly, it is quickly located whether the long link corresponding to the short link to be processed exists, thereby reducing unnecessary resource consumption of the database and improving the efficiency of the server in large data volume scenarios.
[0108] exist Figure 1 Based on the embodiment shown, Figure 2 Schematic diagram of the long link restoration method provided in the embodiment of the present application Figure 2 ,like Figure 2 As shown, the above step 12 may include the following steps:
[0109] Step 21: Use multiple hash functions to perform hash calculations on the short links to be processed to obtain multiple target hash values.
[0110] In this step, for the short link to be processed, each hash function is used to perform hash calculation on the short link to be processed respectively to obtain a hash value corresponding to each hash function, that is, multiple target hash values.
[0111] Step 22: Modulo the integer index values corresponding to the multiple target hash values and the length of the bit array to obtain the target position of the short link to be processed in the bit array.
[0112] In this step, for multiple target hash values, the integer index value corresponding to each target hash value is determined respectively.
[0113] Then, the modulus is taken for each integer index value and the length of the bit array, and the obtained remainder is used as the position of the short link in the bit array, and the position corresponding to each integer index value in the bit array is used as the target position.
[0114] The long link restoration method provided in the embodiment of the present application uses multiple hash functions to perform hash calculations on the short links to be processed to obtain multiple target hash values, and modulo the integer index values corresponding to the multiple target hash values and the length of the bit array to obtain the target position of the short link to be processed in the bit array. In this technical solution, the short link to be processed is compressed into the form of an array using a hash function to determine whether the long link corresponding to the short link to be processed exists.
[0115] Based on the above embodiments, Figure 3 Schematic diagram of the long link restoration method provided in the embodiment of the present application Figure 3 ,like Figure 3 As shown, the above step 13 may include the following steps:
[0116] Step 31: Check in the cache whether the long link corresponding to the short link to be processed exists;
[0117] After the above step 13, that is, before the database queries the long link, it is also possible to query whether there is a long link in the cache of the server to reduce the reading and writing pressure of the database.
[0118] This implementation may be based on the identifier of the short link to be processed, and querying in the cache whether a long link corresponding to the identifier exists.
[0119] Step 32: If there is a long link corresponding to the short link to be processed in the cache, return the page data corresponding to the long link to the user, so that the user's terminal device renders the page corresponding to the long link;
[0120] In this step, if there is a long link corresponding to the short link to be processed in the cache, the page data corresponding to the long link can be returned to the user based on the long link, so that the terminal device can render the page corresponding to the long link according to the page data to achieve promotion purposes.
[0121] Step 33: If the long link corresponding to the short link to be processed does not exist in the cache, the long link determined in the database is backfilled into the cache.
[0122] In this step, if the long link corresponding to the short link to be processed is not determined in the cache, the corresponding long link can be determined in the database and the long link is backfilled into the cache.
[0123] Furthermore, if the long link corresponding to the short link to be processed does not exist in the database, an error reminder is returned to the user, and the error reminder is used to prompt the user that the page of the long link corresponding to the short link to be processed does not exist.
[0124] If the long link corresponding to the short link to be processed is not determined in the database, then referring to the above embodiment, the reminder information sent to the terminal device, the page displayed on the terminal device side is 404.
[0125] In addition, when the user accesses the non-existent short link to be processed again, the array positioning solution is used after hash calculation to quickly determine that the short link to be processed may exist, and the cache is accessed again to obtain that the short link to be processed does not exist in the database, and the user is returned to the 404 interface.
[0126] The long link restoration method provided in the embodiment of the present application queries whether the long link corresponding to the short link to be processed exists in the cache. If the long link corresponding to the short link to be processed exists in the cache, the page data corresponding to the long link is returned to the user so that the user's terminal device can render the page corresponding to the long link. If the long link corresponding to the short link to be processed does not exist in the cache, the long link determined in the database is backfilled into the cache. In this technical solution, the method of predetermining the long link in the cache is also conducive to reducing the access pressure of the database.
[0127] Based on the above embodiments, Figure 4 Schematic diagram of the long link restoration method provided in the embodiment of the present application Figure 4 ,like Figure 4 As shown, the determination of the first bit array is explained:
[0128] Step 1. Start;
[0129] Step 2: Initialize the bit array of the short link of the existing long link;
[0130] Step 3: Use different hash functions to perform hash calculations on each short link;
[0131] Step 4: Get multiple hash values for each short link;
[0132] Step 5: Process multiple hash values to obtain multiple integer index values;
[0133] Step 6: Multiple integer index values and bit arrays are used to calculate remainders;
[0134] Step 7, set 1 at the corresponding position of multiple remainder values in the bit array, and cache the bit array after setting;
[0135] Step 8. End.
[0136] Further, Figure 5 Schematic diagram of the long link restoration method provided in the embodiment of the present application Figure 5 ,like Figure 5 As shown, the determination of the long link is explained:
[0137] Step 1. Start;
[0138] Step 2: Short link access;
[0139] Step 3: Different hash functions are used to perform hash calculations on the short link;
[0140] Step 4: Get multiple hash values;
[0141] Step 5: Multiple hash values are used to calculate multiple integer index values;
[0142] Step 6: Multiple integer index values are modulo the bit array;
[0143] Step 7: Determine whether the corresponding positions of multiple remainder values in the bit array are 1; if so, execute 8; if not, execute 9;
[0144] Step 8: Determine whether there is a short link original data cache in the cache; if so, execute 10 and then execute 12;
[0145] Step 9: Redirect 404 page; then execute 13;
[0146] Step 10. Check whether the short link identifier exists. If yes, go to step 11. If no, go to step 9.
[0147] Step 11: Redirect the long link and execute step 13;
[0148] Step 12: query the database and cache, there is an expiration time, and execute 10;
[0149] Step 13. End.
[0150] It should be understood that: Figure 4 and Figure 5 The technical effects of the illustrated embodiment are similar to those of the above-described embodiment and will not be described in detail here.
[0151] The following are device embodiments of the present application, which can be used to execute the method embodiments of the present application. For details not disclosed in the device embodiments of the present application, please refer to the method embodiments of the present application.
[0152] Figure 6 This is a schematic diagram of the structure of the long link restoration device provided in the embodiment of the present application. Figure 6 As shown, the long link restoration device includes:
[0153] An acquisition module 61 is used to acquire a short link to be processed;
[0154] A first determination module 62, configured to determine a target position of the short link to be processed in a preset bit array according to a plurality of preset hash functions and the short link to be processed;
[0155] A second determination module 63 is used to determine that a long link corresponding to the short link to be processed exists if the target position and the value at the same position in at least one first bit array are both preset values, and the first bit array is a bit array in which the corresponding position of the short link determined in advance in the cache is filled with a preset value;
[0156] The third determining module 64 is used to determine the long link corresponding to the short link to be processed in the database according to the short link to be processed.
[0157] In a possible design of the embodiment of the present application, the first determining module 62 is specifically configured to:
[0158] Using multiple hash functions to perform hash calculations on the short links to be processed to obtain multiple target hash values;
[0159] The target position of the short link to be processed in the bit array is obtained by taking the modulo of the integer index values corresponding to the multiple target hash values and the length of the bit array.
[0160] In another possible design of the embodiment of the present application, if the target position and the value at the same position in at least one first position array are both preset values, after determining that the long link corresponding to the short link to be processed exists, the second determination module 63 is further used to:
[0161] Check in the cache whether the long link corresponding to the short link to be processed exists;
[0162] If there is a long link corresponding to the short link to be processed in the cache, the page data corresponding to the long link is returned to the user, so that the user's terminal device renders the page corresponding to the long link;
[0163] If there is no long link corresponding to the short link to be processed in the cache, the long link determined in the database is backfilled into the cache.
[0164] Optionally, returns a module for:
[0165] If the long link corresponding to the short link to be processed does not exist in the database, an error reminder is returned to the user, and the error reminder is used to prompt the user that the page of the long link corresponding to the short link to be processed does not exist.
[0166] In another possible design of the embodiment of the present application, after determining the target position of the short link to be processed in the preset bit array according to the preset multiple hash functions and the short link to be processed, the return module is also used to:
[0167] If the target position does not have a preset value as the value at the same position in at least one of the first positions in the array, an error reminder is returned to the user, and the error reminder is used to prompt the user that the page of the long link corresponding to the short link to be processed does not exist.
[0168] In another possible design of the embodiment of the present application, if the values at the target positions are all preset values, before determining that the long link corresponding to the short link to be processed exists, the acquisition module 61 is further used to:
[0169] Get multiple short links;
[0170] For each short link, multiple hash functions are used to perform hash calculation on the short link to be processed to obtain multiple hash values;
[0171] The position of the short link in the bit array is obtained by taking the modulo of the integer index values corresponding to the multiple hash values and the length of the bit array;
[0172] The value corresponding to the position of the short link in the bit array is filled with a preset value to obtain the first bit array.
[0173] In another possible design of the embodiment of the present application, the return module is further used to:
[0174] The page data corresponding to the long link is returned to the user so that the user's terminal device can render the page corresponding to the long link.
[0175] The long link restoration device provided in the embodiment of the present application can be used to execute the long link restoration method in any of the above embodiments. Its implementation principle and technical effects are similar and will not be repeated here.
[0176] It should be noted that it should be understood that the division of the various modules of the above device is only a division of logical functions. In actual implementation, they can be fully or partially integrated into one physical entity, or they can be physically separated. And these modules can all be implemented in the form of software calling through processing elements; they can also be all implemented in the form of hardware; some modules can also be implemented in the form of software calling through processing elements, and some modules can be implemented in the form of hardware. In addition, all or part of these modules can be integrated together, or they can be implemented independently. The processing element described here can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each module above can be completed by an integrated logic circuit of hardware in the processor element or instructions in the form of software.
[0177] Figure 7 A schematic diagram of the structure of the server provided in the embodiment of the present application, such as Figure 7 As shown, the server may include: a processor 71, a memory 72, and computer program instructions stored in the memory 72 and executable on the processor 71, and the processor 71 implements the method provided in any of the aforementioned embodiments when executing the computer program instructions.
[0178] Optionally, the above-mentioned components of the server may be connected via a system bus.
[0179] The memory 72 may be a separate storage unit or a storage unit integrated in the processor 71. The number of the processor 71 may be one or more.
[0180] It should be understood that the processor 71 can be a central processing unit (CPU), or other general-purpose processors 71, digital signal processors 71 (DSP), application-specific integrated circuits (ASIC), etc. The general-purpose processor 71 can be a microprocessor 71 or the processor 71 can also be any conventional processor 71, etc. The steps of the method disclosed in the present application can be directly embodied as being executed by the hardware processor 71, or can be executed by a combination of hardware and software modules in the processor 71.
[0181] The system bus may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The system bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. The memory 72 may include a random access memory 72 (RAM), and may also include a non-volatile memory 72 (NVM), such as at least one disk memory 72.
[0182] All or part of the steps of the above-mentioned method embodiments can be completed by hardware related to program instructions. The above-mentioned program can be stored in a readable memory 72. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the above-mentioned memory 72 (storage medium) includes: read-only memory 72 (ROM), RAM, flash memory 72, hard disk, solid state hard disk, magnetic tape, floppy disk, optical disk and any combination thereof.
[0183] The server provided in the embodiment of the present application can be used to execute the method provided in any of the above method embodiments. The implementation principles and technical effects are similar and will not be repeated here.
[0184] An embodiment of the present application provides a computer-readable storage medium, in which computer instructions are stored. When the computer instructions are executed on a computer, the computer executes the above method.
[0185] The computer-readable storage medium mentioned above can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory, electrically erasable programmable read-only memory, erasable programmable read-only memory, programmable read-only memory, read-only memory, magnetic memory, flash memory, magnetic disk or optical disk. The readable storage medium can be any available medium that can be accessed by a general or special-purpose computer.
[0186] Optionally, a readable storage medium is coupled to a processor so that the processor can read information from the readable storage medium and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can be located in an application specific integrated circuit (ASIC). Of course, the processor and the readable storage medium can also exist in the device as discrete components.
[0187] An embodiment of the present application also provides a computer program product, which includes a computer program. The computer program is stored in a computer-readable storage medium. At least one processor can read the computer program from the computer-readable storage medium. When the at least one processor executes the computer program, the above method can be implemented.
[0188] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A long link restoration method, characterized in that: include: Get the short link to be processed; Determine the target position of the short link to be processed in a preset bit array according to the preset multiple hash functions and the short link to be processed; If the target position and the value at the same position in at least one first bit array are both preset values, it is determined that the long link corresponding to the short link to be processed exists, and the first bit array is a bit array in which the preset value is filled in the corresponding position of the bit array for the short link pre-determined in the cache; According to the short link to be processed, a long link corresponding to the short link to be processed is determined in a database.
2. The method according to claim 1, characterized in that The determining, according to the preset multiple hash functions and the short link to be processed, a target position of the short link to be processed in a preset bit array includes: Using the multiple hash functions to perform hash calculations on the short links to be processed to obtain multiple target hash values; The target position of the short link to be processed in the bit array is obtained by performing modulo operation on the integer index values corresponding to the multiple target hash values and the length of the bit array.
3. The method according to claim 1, characterized in that After determining that a long link corresponding to the short link to be processed exists if the target position and the value at the same position in at least one first bit array are both preset values, the method further includes: Querying the cache whether a long link corresponding to the short link to be processed exists; If the cache contains a long link corresponding to the short link to be processed, returning page data corresponding to the long link to the user, so that the user's terminal device renders the page corresponding to the long link; If the long link corresponding to the short link to be processed does not exist in the cache, the long link determined in the database is backfilled into the cache.
4. The method according to claim 3, characterized in that The method further comprises: If the long link corresponding to the short link to be processed does not exist in the database, an error reminder is returned to the user, where the error reminder is used to prompt the user that the page of the long link corresponding to the short link to be processed does not exist.
5. The method according to claim 1, characterized in that After determining the target position of the short link to be processed in a preset bit array according to the preset multiple hash functions and the short link to be processed, the method further includes: If the target position does not have a preset value as the value at the same position in at least one first position array, an error reminder is returned to the user, and the error reminder is used to prompt the user that the page of the long link corresponding to the short link to be processed does not exist.
6. The method according to any one of claims 1 to 5, characterized in that: Before determining that a long link corresponding to the short link to be processed exists if the target position and the value at the same position in at least one first bit array are both preset values, the method further includes: Obtaining the multiple short links; For each short link, use the multiple hash functions to perform hash calculation on the short link to be processed to obtain multiple hash values; Obtaining the position of the short link in the bit array by performing modulo operation on the integer index values corresponding to the multiple hash values and the length of the bit array; The value corresponding to the position of the short link in the bit array is filled with the preset value to obtain the first bit array.
7. The method according to claim 1, characterized in that The method further comprises: The page data corresponding to the long link is returned to the user so that the user's terminal device renders the page corresponding to the long link.
8. A long link restoration device, characterized in that: include: The acquisition module is used to obtain the short link to be processed; A first determination module, configured to determine a target position of the short link to be processed in a preset bit array according to a plurality of preset hash functions and the short link to be processed; A second determination module is configured to determine that a long link corresponding to the short link to be processed exists if the target position and the value at the same position in at least one first bit array are both preset values, and the first bit array is a bit array in which the short link pre-determined in the cache is filled with the preset value at the corresponding position in the bit array; The third determining module is used to determine the long link corresponding to the short link to be processed in the database according to the short link to be processed.
9. A server, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Data query request processing method and apparatus, and electronic device
CN106445944A
Data processing method and device and server
CN110489405A
Page query method and device
CN115525846A
