CN117828201A - High performance short link generation method - Google Patents

High performance short link generation method Download PDF

Info

Publication number
CN117828201A
CN117828201A CN202311820966.5A CN202311820966A CN117828201A CN 117828201 A CN117828201 A CN 117828201A CN 202311820966 A CN202311820966 A CN 202311820966A CN 117828201 A CN117828201 A CN 117828201A
Authority
CN
China
Prior art keywords
service
short link
link
short
memory
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.)
Pending
Application number
CN202311820966.5A
Other languages
Chinese (zh)
Inventor
代存折
王彬
石小明
吴奕刚
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Arcvideo Technology Co ltd
Original Assignee
Hangzhou Arcvideo Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Arcvideo Technology Co ltd filed Critical Hangzhou Arcvideo Technology Co ltd
Priority to CN202311820966.5A priority Critical patent/CN117828201A/en
Publication of CN117828201A publication Critical patent/CN117828201A/en
Pending legal-status Critical Current

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a high-performance short-link generation method, which comprises the following steps: setting a short link generation system comprising a demand server, a generation server, an access client and a timing service, and setting a release service to deliver the collected long link information to a generation server for processing; setting a computing service to compute a short link based on a long link; setting memory service to store long-short link correspondence in a memory; setting an access client to trigger access of the short link; setting a verification service to verify the validity of the current short link, updating the conflicted short link according to the verification result correction service, and refreshing the cache at the same time; setting an access client to receive a short link change notice and update the short link change notice in real time; setting timing service timing to the correction service timing to trigger the cleaning service, correcting according to the condition of the existing short link, cleaning the cache or updating the memory, and finally notifying the emptied short link information to the demand service end.

Description

High performance short link generation method
Technical Field
The invention belongs to the technical field of network information transmission, and particularly relates to a high-performance short-link generation method.
Background
The short link generation technology is a technology that has been rising in recent years with the rapid development of the internet and the mobile internet. With explosive growth of network content and explosive growth of the number of users, conventional long-link addresses become longer and longer, and are difficult to memorize and share. Therefore, the short link generation technology is generated, and the long link address can be converted into the short link address, so that the user can conveniently and quickly share and access the short link address, and the short link generation technology is required to be used for improving the user experience and the access speed no matter social media, e-commerce websites, news websites or other various applications. Thus, short-link generation technology has become an integral part of internet applications. The prior art has the following defects: (1) performance problems: many conventional short link generation methods have low performance when facing a large number of requests, and cannot meet the requirements of high concurrency scenes. This may lead to problems with system delay, jamming, etc., affecting the user experience. (2) conflict problem: because the generation of the short link address often adopts a fixed algorithm or rule, address conflict is easy to generate. This may result in the same short link address being used by different long links, causing confusion and misleading. (3) safety problem: some short link generation services may have security holes that are easily exploited by malicious attackers. For example, an attacker may exploit a vulnerability of the short link generation service, falsify or tamper with the short link address, resulting in a user accessing malicious content or suffering from a network attack. (4) update and maintenance problems: when the long link address changes, the conventional short link generation method may not be able to update the short link address in time. This may result in users accessing links that are out of date or invalid, affecting user experience and system stability.
Disclosure of Invention
In view of the above problems, the present invention provides a high-performance short-link generation method.
In order to solve the technical problems, the invention adopts the following technical scheme:
a high performance short link generation method comprising the steps of:
setting a short link generation system comprising a demand service end, a generation service end, an access client end and a timing service, wherein the demand service end comprises a release service and an update service, and the generation service end comprises a calculation service, a verification service, a correction service, a memory service and a cache service;
the release service is set to transmit the collected long link information to the generation server for processing;
setting a computing service to compute a short link based on a long link;
setting memory service to store long-short link correspondence in a memory;
setting an access client to trigger access of the short link;
setting a verification service to verify the validity of the current short link, updating the conflicted short link according to the verification result correction service, and refreshing the cache at the same time; setting an access client to receive a short link change notice and update the short link change notice in real time;
the access client searches long links in the memory service according to the short links, and returns and updates the time stamp if the long links exist; otherwise, searching in the cache service, storing the long link in a memory if found, and returning to the 404 state code if not found;
setting timing service timing to the correction service timing to trigger the cleaning service, correcting according to the condition of the existing short link, cleaning the cache or updating the memory, and finally notifying the emptied short link information to the demand service end.
In a possible implementation manner, the algorithm rule for calculating the short link by the setting calculation service based on the long link is as follows: the method comprises the steps of calculating a 32-bit MD5 value of a long link, dividing the MD5 into 8 groups, dividing each 4 groups into one group, defining 64 printable character sets, taking a result of each group through a modulo 62 operation as an index to take out characters in a corresponding character set, finally obtaining 8-bit characters, taking the 8-bit characters as a short link to respond to a release service of a demand server, taking a short link as a key in a key value pair mode, taking the long link as a value, and taking a current timestamp as an attached time stamp to be stored in a memory of a generation server, so that a main thread for generating the short link is finished.
In one possible implementation manner, the setting the memory service to store the long-short link correspondence relationship in the memory includes: the storage structure is a set of key-value pairs, with short links as keys and long links + underlining + current timestamp as values.
In a possible implementation manner, the setting and checking service checks validity of the current short link includes:
judging whether the short link exists in the key value pair set of the memory according to the short link, judging whether the short link exists in the cache if the short link does not exist, if the short link does not exist in the cache, meeting the requirements, having no conflict, and delivering the correction service to perform cache processing, wherein update notification is not needed in the case; if the currently generated short link exists in the memory or the cache, the conflict is indicated, and the corresponding conflict short link is updated through the correction service and the cache is refreshed at the same time because the current short link is responded.
In a possible implementation manner, the delivering the correction service to perform caching includes:
when the correction service receives the short link information of the check service without conflict, the short link is used as a key of the cache, the long link is used as a value of the cache, and the current timestamp is attached to the correction service and stored in the cache service.
In a possible implementation manner, the updating, by the correction service, the short link corresponding to the conflict includes:
when the correction service receives the short link information with conflict in the verification service, the new short link is recalculated by the existing short link information through the rule of the calculation service, except that the parameter of the previous calculation service is a long link and the parameter of the calculation service is a short link, then the newly generated short link and the corresponding long link information are notified to the demand service end so as to facilitate the subsequent updating, and meanwhile, the new short link key value pair information is inserted into the cache service.
In a possible implementation manner, the access client searches a long link in the memory service according to the short link, and if the long link exists, returns and updates the time stamp; otherwise, searching in the cache service, storing the found data into the memory and returning the long link comprises: setting an access client to access a short link, reading a memory service by the access client, dividing a corresponding value by an underline if the short link transmitted by the access client exists in the key value pair set during reading, responding to the client by using the information before the underline as a long link through a 302 state code, updating a timestamp after the underline into a latest timestamp, updating the latest timestamp into a memory, returning to a cache service if the short link transmitted by the client does not exist in the key value pair set during reading, and inquiring if the short link transmitted by the client exists in the cache, inserting the short link into the memory key value pair according to the rule of the memory service and responding to the corresponding long link through the 302 state code.
The invention has the following beneficial effects:
(1) High performance: by adopting an efficient algorithm and an optimization technology, the short link generation method can process a large number of requests and provide high-performance short link generation service.
(2) Avoiding collisions: by adopting a unique checksum correction mechanism, the short link generation method can ensure the uniqueness and the correctness of the generated short link address and avoid address conflict.
(3) Automatic updating and maintaining: by tightly matching with the demand server, the short link generation method can update the short link address in time, and ensure that the user accesses the latest and effective link.
Drawings
FIG. 1 is a flow chart of steps of a high performance short link generation method according to an embodiment of the present invention;
fig. 2 is a schematic block diagram of a short link generation system in a high-performance short link generation method according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are some, but not all embodiments of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Referring to fig. 1, a flowchart of steps of a high-performance short-link generation method according to an embodiment of the present invention is shown, including the following steps:
s10, setting a short link generation system comprising a demand service end, a generation service end, an access client end and a timing service, wherein the demand service end comprises a release service and an update service, and the generation service end comprises a calculation service, a verification service, a correction service, a memory service and a cache service as shown in fig. 2;
s20, the distribution service is set to deliver the collected long link information to the generation server for processing;
in a specific application example, after the processing of the generation server is completed, the corresponding short link information is responded to the client for subsequent access.
S30, setting a calculation service to calculate a short link based on the long link;
s40, setting memory service to store long-short link correspondence in a memory;
s50, setting an access client to trigger access of the short link;
s60, setting a verification service to verify the validity of the current short link, and updating the conflicted short link according to the verification result correction service and refreshing the cache; setting an access client to receive a short link change notice and update the short link change notice in real time;
s70, the access client searches long links in the memory service according to the short links, and if the long links exist, the access client returns and updates the time stamp; otherwise, searching in the cache service, storing the long link in a memory if found, and returning to the 404 state code if not found;
and S80, setting timing service timing to the correction service timing to trigger the cleaning service, correcting according to the condition of the existing short link, cleaning the cache or updating the memory, and finally notifying the emptied short link information to the demand server.
The set timing service is used for maintaining high performance of the system through the timing trigger cleaning logic, and meanwhile, only active short links are reserved in the memory, so that the timing service is independent of the generating service end, the independence of the generating service end is improved, and the situation that the timing cannot be triggered due to internal reasons, so that data overflow is caused is avoided.
In a high-performance short link generation method according to another embodiment of the present invention, in S30, an algorithm rule for setting a calculation service to calculate a short link based on a long link is: the method comprises the steps of calculating a 32-bit MD5 value of a long link, dividing the MD5 into 8 groups, dividing each 4 groups into one group, defining 64 printable character sets, taking a result of each group through a modulo 62 operation as an index to take out characters in a corresponding character set, finally obtaining 8-bit characters, taking the 8-bit characters as a short link to respond to a release service of a demand service end, taking a short link as a key in a key value pair mode, taking the long link as a value, and taking a current timestamp as an attached time stamp to exist in a memory of a generation server, wherein a main thread for generating the short link is finished, and carrying out processing on the short link by a verification service in a follow-up asynchronous mode.
In a method for generating a short link with high performance according to still another embodiment of the present invention, setting a memory service in S40 to store a short link correspondence in a memory includes: the storage structure is a set of key-value pairs, with short links as keys and long links + underlining + current timestamp as values. The cache service is used for persisting the corresponding relation of the long and short links to prevent information loss, the memory service is used for improving performance, and in order to prevent information loss when the memory service is restarted or abnormal, the storage structure of the cache is consistent with the memory service.
In a method for generating a high-performance short link according to another embodiment of the present invention, the setting check service in S60 checks validity of a current short link includes: judging whether the short link exists in the key value pair set of the memory according to the short link, judging whether the short link exists in the cache if the short link does not exist, if the short link does not exist in the cache, meeting the requirements, having no conflict, and delivering the correction service to perform cache processing, wherein update notification is not needed in the case; if the currently generated short link exists in the memory or the cache, the conflict is indicated, and the corresponding conflict short link is updated through the correction service and the cache is refreshed at the same time because the current short link is responded.
Further, the delivering the correction service to the cache processing comprises:
when the correction service receives the short link information of the check service without conflict, the short link is used as a key of the cache, the long link is used as a value of the cache, and the current timestamp is attached to the long link and stored in the cache service, so that the cache is put in the step to provide the efficiency of generating the short link, because if the correction service is put in a main line flow for generating the short link, the interaction time with the cache service is consumed once, and the performance bottleneck exists in a high concurrency scene.
Further, updating the corresponding conflicted short link by the correction service includes:
when the correction service receives the short link information with conflict in the verification service, the new short link is recalculated by the existing short link information through the rule of the calculation service, except that the parameter of the previous calculation service is a long link and the parameter of the calculation service is a short link, then the newly generated short link and the corresponding long link information are notified to the demand service end so as to facilitate the subsequent updating, and meanwhile, the new short link key value pair information is inserted into the cache service.
In a high-performance short link generation method according to a further embodiment of the present invention, in S70, an access client searches for a long link in a memory service according to a short link, and if there is a long link, returns and updates a timestamp; otherwise, searching in the cache service, storing the found data into the memory and returning the long link comprises: setting an access client to access a short link, reading a memory service by the access client, dividing a corresponding value by an underline if the short link transmitted by the access client exists in the key value pair set during reading, responding to the client by using the information before the underline as a long link through a 302 state code, updating a timestamp after the underline into a latest timestamp, updating the latest timestamp into a memory, returning to a cache service if the short link transmitted by the client does not exist in the key value pair set during reading, and inquiring if the short link transmitted by the client exists in the cache, inserting the short link into the memory key value pair according to the rule of the memory service and responding to the corresponding long link through the 302 state code.
The method for generating the short link with high performance further comprises the steps of setting an update service to receive an update notification of the generation service end and feeding the update notification back to the access client, and notifying the update service of a failure result and an update result when the short link of the correction service discovery part in the generation service end fails or is updated after short link collision.
In a high-performance short link generation method according to another embodiment of the present invention, setting a timing service timing to a correction service timing to trigger a cleaning service in S80, and correcting according to the existing short link condition includes: when the correction service receives the request of timing service, it is used to clean short link information which is not accessed for a long time and is used to reduce the data storage and provide access performance, the specific judgment logic is to compare the time stamp stored in the buffer memory at the time with the current time, if the time stamp is longer than the time specified by the service, for example, 24 hours, it is necessary to judge whether the short link exists in the memory again and in the time specified by the service, the step is added because the newly accessed short link is recorded in the memory and is not synchronized to the buffer memory, if the short link has access, the cleaning is not needed, the time stamp in the buffer memory is updated to the time stamp in the memory synchronously, the next time is prevented from being repeatedly executed, if the short link information which has no access is needed to be cleaned, the link information in the buffer memory is emptied synchronously, and finally the emptied short link information is notified to the demand service end, so that the subsequent operation is facilitated.
By adopting the high-performance short link generation method, a large number of requests can be processed by adopting an efficient algorithm and an optimization technology, and high-performance short link generation service is provided. Meanwhile, by adopting a unique check sum correction mechanism, the uniqueness and the correctness of the generated short link address can be ensured, and address conflict is avoided. By tightly matching with the demand server, the short link address can be updated in time, and the user is ensured to access the latest and effective link.
It should be understood that the exemplary embodiments described herein are illustrative and not limiting. Although one or more embodiments of the present invention have been described with reference to the accompanying drawings, it will be understood by those of ordinary skill in the art that various changes in form and details may be made therein without departing from the spirit and scope of the present invention as defined by the following claims.

Claims (7)

1. A high performance short link generation method, comprising the steps of:
setting a short link generation system comprising a demand service end, a generation service end, an access client end and a timing service, wherein the demand service end comprises a release service and an update service, and the generation service end comprises a calculation service, a verification service, a correction service, a memory service and a cache service;
the release service is set to transmit the collected long link information to the generation server for processing;
setting a computing service to compute a short link based on a long link;
setting memory service to store long-short link correspondence in a memory;
setting an access client to trigger access of the short link;
setting a verification service to verify the validity of the current short link, updating the conflicted short link according to the verification result correction service, and refreshing the cache at the same time; setting an access client to receive a short link change notice and update the short link change notice in real time;
the access client searches long links in the memory service according to the short links, and returns and updates the time stamp if the long links exist; otherwise, searching in the cache service, storing the long link in a memory if found, and returning to the 404 state code if not found;
setting timing service timing to the correction service timing to trigger the cleaning service, correcting according to the condition of the existing short link, cleaning the cache or updating the memory, and finally notifying the emptied short link information to the demand service end.
2. The high-performance short link generation method according to claim 1, wherein the algorithm rule for setting the calculation service to calculate the short link based on the long link is: the method comprises the steps of calculating a 32-bit MD5 value of a long link, dividing the MD5 into 8 groups, dividing each 4 groups into one group, defining 64 printable character sets, taking a result of each group through a modulo 62 operation as an index to take out characters in a corresponding character set, finally obtaining 8-bit characters, taking the 8-bit characters as a short link to respond to a release service of a demand server, taking a short link as a key in a key value pair mode, taking the long link as a value, and taking a current timestamp as an attached time stamp to be stored in a memory of a generation server, so that a main thread for generating the short link is finished.
3. The method for generating a high-performance short link according to claim 1, wherein the setting the memory service to store the long-short link correspondence in the memory comprises: the storage structure is a set of key-value pairs, with short links as keys and long links + underlining + current timestamp as values.
4. The high-performance short-link generation method of claim 1, wherein the setting check service checking validity of the current short link comprises:
judging whether the short link exists in the key value pair set of the memory according to the short link, judging whether the short link exists in the cache if the short link does not exist, if the short link does not exist in the cache, meeting the requirements, having no conflict, and delivering the correction service to perform cache processing, wherein update notification is not needed in the case; if the currently generated short link exists in the memory or the cache, the conflict is indicated, and the corresponding conflict short link is updated through the correction service and the cache is refreshed at the same time because the current short link is responded.
5. The method for generating a high-performance short link as recited in claim 4, wherein said delivering the correction service for caching comprises:
when the correction service receives the short link information of the check service without conflict, the short link is used as a key of the cache, the long link is used as a value of the cache, and the current timestamp is attached to the correction service and stored in the cache service.
6. The method for generating high-performance short links according to claim 4, wherein updating the corresponding conflicted short links by the correction service comprises:
when the correction service receives the short link information with conflict in the verification service, the new short link is recalculated by the existing short link information through the rule of the calculation service, except that the parameter of the previous calculation service is a long link and the parameter of the calculation service is a short link, then the newly generated short link and the corresponding long link information are notified to the demand service end so as to facilitate the subsequent updating, and meanwhile, the new short link key value pair information is inserted into the cache service.
7. The method for generating high-performance short links according to claim 1, wherein the access client searches long links in the memory service according to the short links, and if the long links exist, returns and updates the time stamp; otherwise, searching in the cache service, storing the found data into the memory and returning the long link comprises: setting an access client to access a short link, reading a memory service by the access client, dividing a corresponding value by an underline if the short link transmitted by the access client exists in the key value pair set during reading, responding to the client by using the information before the underline as a long link through a 302 state code, updating a timestamp after the underline into a latest timestamp, updating the latest timestamp into a memory, returning to a cache service if the short link transmitted by the client does not exist in the key value pair set during reading, and inquiring if the short link transmitted by the client exists in the cache, inserting the short link into the memory key value pair according to the rule of the memory service and responding to the corresponding long link through the 302 state code.
CN202311820966.5A 2023-12-27 2023-12-27 High performance short link generation method Pending CN117828201A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311820966.5A CN117828201A (en) 2023-12-27 2023-12-27 High performance short link generation method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311820966.5A CN117828201A (en) 2023-12-27 2023-12-27 High performance short link generation method

Publications (1)

Publication Number Publication Date
CN117828201A true CN117828201A (en) 2024-04-05

Family

ID=90523918

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311820966.5A Pending CN117828201A (en) 2023-12-27 2023-12-27 High performance short link generation method

Country Status (1)

Country Link
CN (1) CN117828201A (en)

Similar Documents

Publication Publication Date Title
US11201810B2 (en) Data transmission method and apparatus
CN112073405B (en) Webpage data loading method and device, computer equipment and storage medium
CN102117309B (en) Data caching system and data query method
US8539160B2 (en) Asynchronous cache refresh for systems with a heavy load
US10275347B2 (en) System, method and computer program product for managing caches
US9286293B2 (en) Populating and using caches in client-side caching
CN105426321B (en) Using RDMA close friend's caching method of remote location information
WO2020143317A1 (en) Fragmented file verification method and terminal device
TW201824047A (en) Attack request determination method, apparatus and server
CN112084258A (en) Data synchronization method and device
CN102882974A (en) Method for saving website access resource by website identification version number
US20230102617A1 (en) Repeat transaction verification method, apparatus, and device, and medium
US9928174B1 (en) Consistent caching
EP2568386A1 (en) Method for accessing cache and fictitious cache agent
CN112527844A (en) Data processing method and device and database architecture
CN114598748A (en) Method, device and system for refreshing cache resources
US20230336368A1 (en) Block chain-based data processing method and related apparatus
US11206302B2 (en) Method and device for feeding back a resource file
US11829345B2 (en) Distributed data processing
CN106959975B (en) Transcoding resource cache processing method, device and equipment
CN117828201A (en) High performance short link generation method
US8281000B1 (en) Variable-length nonce generation
CN114301696B (en) Malicious domain name detection method, malicious domain name detection device, computer equipment and storage medium
CN111586438B (en) Method, device and system for processing service data
CN112015818B (en) UUID (unified user identifier) generation method, device, equipment and medium for distributed graph database

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