Method and apparatus for generating a unique identifier

By working together with the identifier generator, verifier, and registry center, unique, ordered, and short identifiers are generated and verified, solving the problems of global uniqueness and resource waste in existing technologies and achieving efficient identifier generation.

CN115220793BActive Publication Date: 2026-01-13RENGUO (GUANGZHOU) TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210633286.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-07
Publication Date
2026-01-13
Estimated Expiration
2042-06-07

AI Technical Summary

Technical Problem

Existing methods for generating unique identifiers have limitations in big data application scenarios. They cannot guarantee global uniqueness, are too long, computationally complex and wasteful of resources, and pose security risks.

Method used

The identifier generator receives generation requests, the verifier performs legality and uniqueness checks, the registry center stores the target identifier, ensuring the uniqueness, order and brevity of the identifier, and uses time generation elements and auxiliary generation elements to generate candidate identifiers, and performs legality and uniqueness checks.

Benefits of technology

It achieves globally unique, ordered, short, and computationally simple identifier generation, avoiding resource waste, adapting to big data application scenarios, and improving system stability and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115220793B_ABST
    Figure CN115220793B_ABST
Patent Text Reader

Abstract

The application discloses a kind of generation method and device of unique identifier, method includes: through identifier generator, the generation request of unique identifier issued by client is received, and candidate identifier is generated;Through the legality verification and uniqueness verification of the candidate identifier by verifier, the candidate identifier that passes through legality verification and uniqueness verification is determined as target identifier;Through the storage of target identifier that passes through legality verification and uniqueness verification by registration center;The target identifier is fed back to the client.The application can ensure the characteristics of the uniqueness of identifier, order, length short, simple calculation simultaneously, can be widely applied in computer technology field.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a method and apparatus for generating a unique identifier. Background Technology

[0002] In system development, unique identifiers are often needed to uniquely identify data records, such as inserting a data record into a database, writing a log record to a log collector, or generating an order record in a message broker. Currently, there are several methods for generating unique identifiers; however, each method has its own drawbacks.

[0003] 1. Utilize the auto-incrementing data type or modifiers provided by the database management system. For example, in PostgreSQL, use `serial` as the column data type. Similarly, in MySQL, use `AUTO_INCREMENT` to modify the column. Identifiers generated in this way have the following drawbacks: 1) They can only achieve local uniqueness, not global uniqueness; for example, identifiers in the `employee` and `item` database tables will be duplicated. 2) The data type has a limited number of bits, supporting a maximum of only 64 bits. In big data applications, the auto-incrementing sequence will be exhausted, ultimately causing the system to malfunction.

[0004] 2. Utilize the auto-increment function provided by the database management system. For example, in PostgreSQL, creating a global sequence number and declaring that the column value is generated by the NEXTVAL('sequence number name') function can ensure global uniqueness, but it has the following drawbacks: the sequence number can only be up to 64 bits long. In big data application scenarios, the auto-increment sequence will be exhausted, eventually causing the system to malfunction.

[0005] 3. Use random algorithms to generate unique identifiers. Common algorithms include UUID or GUID. Identifiers generated in this way have the following drawbacks: 1) The generated identifier occupies 128 bits, wasting computing and storage resources; 2) The generated identifier is unordered, resulting in low retrieval efficiency; 3) The generated identifier may be duplicated, and global uniqueness cannot be guaranteed; 4) The device's MAC address is exposed, posing a security risk.

[0006] 4. Identifiers are derived using complex arrangements and algorithms. However, this approach has the following drawback: the generation algorithm is overly complex. Summary of the Invention

[0007] In view of this, embodiments of the present invention provide a method and apparatus for generating unique identifiers, which can simultaneously ensure the uniqueness, orderliness, short length, and simple calculation of the identifiers.

[0008] One aspect of this invention provides a method for generating a unique identifier, comprising:

[0009] The identifier generator receives a request from the client to generate a unique identifier and generates candidate identifiers.

[0010] The candidate identifiers are validated for legality and uniqueness by a validator, and the candidate identifiers that pass the validity and uniqueness checks are determined as the target identifiers.

[0011] The registry center stores target identifiers that have passed both validity and uniqueness checks.

[0012] The target identifier is then fed back to the client.

[0013] Optionally, the deployment methods of the identifier generator, the verifier, and the registration center include:

[0014] The identifier generator, the verifier, and the registration center are deployed together on the same terminal.

[0015] Alternatively, the identifier generator, the verifier, and the registration center can be deployed to three different terminals.

[0016] Alternatively, any two of the identifier generator, the verifier, and the registration center can be deployed to the first terminal, and the remaining one can be deployed to the second terminal.

[0017] The terminals include, but are not limited to: smartphones, computers, virtual machines, containers, cloud servers, database management systems, smart voice interaction devices, smart home appliances, vehicle terminals, aircraft, independent physical servers, server clusters or distributed systems composed of multiple physical servers.

[0018] Optionally, the identifier generator generates candidate identifiers by including the following steps:

[0019] Based on the time of receiving the generation request, determine the time generation element of the identifier;

[0020] The candidate identifier is generated based on the time generation element;

[0021] Based on the application scenario of the client, add auxiliary generation elements to the candidate identifier;

[0022] The auxiliary generation elements include, but are not limited to: random number generation elements, random string generation elements, ordered number generation elements, or ordered string generation elements.

[0023] Optionally, the step of performing legality and uniqueness checks on the candidate identifier using a validator includes:

[0024] When the identifier generator is deployed on a mobile terminal, and the candidate identifier is generated based on the device time of the mobile terminal, the verifier checks whether the time when the candidate identifier is received exceeds the allowed configurable time window to determine the legality verification result of the candidate identifier.

[0025] The verifier compares the received candidate identifier with the identifier stored in the registry center to determine whether the candidate identifier is duplicated with the identifier stored in the registry center, thereby determining the uniqueness verification result of the candidate identifier.

[0026] Optionally, storing the target identifiers that have passed the validity and uniqueness checks through the registration center includes:

[0027] Configure the forward and backward time windows of the registry center;

[0028] The time range for storable identifiers in the registry center is determined based on the forward time window and the backward time window.

[0029] Identifiers that are outside the specified time range will be logically or physically cleaned up.

[0030] The implementation methods of the registration center include, but are not limited to: data files, cache middleware that supports data persistence, or database tables.

[0031] Optionally, the step of logically or physically cleaning up identifiers that exceed the time range includes, but is not limited to:

[0032] The TTL function of the database management system is used to specify the lifespan of the identifier of the record. When the TTL of the identifier is exhausted, the record corresponding to the identifier is automatically deleted.

[0033] Alternatively, a garbage collector can be used, employing timed or event-triggered methods to reclaim invalid identifier records.

[0034] Optionally, the method further includes:

[0035] The storage time window of the registry center is dynamically configured, wherein the storage time window is used to represent the storage time of the identifiers stored in the registry center; the registry center stores identifier records for a period of time before and after the storage time.

[0036] The time window of the verifier is smaller than the storage time window of the registration center;

[0037] The time difference between the start time of the verifier's storage time window and the start time of the registration center's time window is greater than a first threshold.

[0038] The time difference between the end time of the registration center's time window and the end time of the verifier's storage time window is greater than the second threshold.

[0039] Another aspect of the present invention provides a unique identifier generation apparatus, comprising:

[0040] The first module is used to receive a request from the client to generate a unique identifier and to generate candidate identifiers.

[0041] The second module is used to perform legality and uniqueness checks on the candidate identifiers through a validator, and to determine the candidate identifiers that pass the legality and uniqueness checks as the target identifiers.

[0042] The third module is used to store target identifiers that have passed the validity and uniqueness checks through the registration center;

[0043] The fourth module is used to feed back the target identifier to the client.

[0044] Another aspect of this invention provides a system for generating unique identifiers, comprising:

[0045] The client is used to send requests for the generation of unique identifiers and to receive the generated target identifiers.

[0046] The identifier generator is used to generate candidate identifiers based on the unique identifier generation request sent by the client.

[0047] A validator is used to perform legality and uniqueness checks on the candidate identifiers, and to determine the candidate identifiers that pass the legality and uniqueness checks as the target identifiers.

[0048] The registry center is used to store target identifiers that have passed validity and uniqueness checks.

[0049] Another aspect of the present invention provides an electronic device, including a processor and a memory;

[0050] The memory is used to store programs;

[0051] The processor executes the program to implement the method described above.

[0052] This invention also discloses a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device can read the computer instructions from the computer-readable storage medium and execute the computer instructions, causing the computer device to perform the aforementioned method.

[0053] In embodiments of the present invention, an identifier generator receives a request from a client to generate a unique identifier and generates candidate identifiers; a validator performs validity and uniqueness checks on the candidate identifiers, and identifies the candidate identifiers that pass both checks as the target identifier; a registry center stores the target identifiers that pass both checks; and the target identifiers are then sent back to the client. This invention simultaneously ensures the uniqueness, orderliness, brevity, and computational simplicity of identifiers. Attached Figure Description

[0054] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0055] Figure 1 This is a timing diagram of the identifier generation method according to an embodiment of the present invention. Detailed Implementation

[0056] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0057] In view of the problems existing in the prior art, this invention application aims to provide a method and apparatus for generating unique identifiers for data records, which can simultaneously ensure the uniqueness, orderliness, short length, and simple calculation of the identifiers.

[0058] Specifically, one aspect of this invention provides a method for generating a unique identifier, comprising:

[0059] The identifier generator receives a request from the client to generate a unique identifier and generates candidate identifiers.

[0060] The candidate identifiers are validated for legality and uniqueness by a validator, and the candidate identifiers that pass the validity and uniqueness checks are determined as the target identifiers.

[0061] The registry center stores target identifiers that have passed both validity and uniqueness checks.

[0062] The target identifier is then fed back to the client.

[0063] Optionally, the deployment methods of the identifier generator, the verifier, and the registration center include:

[0064] The identifier generator, the verifier, and the registration center are deployed together on the same terminal.

[0065] Alternatively, the identifier generator, the verifier, and the registration center can be deployed to three different terminals.

[0066] Alternatively, any two of the identifier generator, the verifier, and the registration center can be deployed to the first terminal, and the remaining one can be deployed to the second terminal.

[0067] The terminals include, but are not limited to: smartphones, computers, virtual machines, containers, cloud servers, database management systems, smart voice interaction devices, smart home appliances, vehicle terminals, aircraft, independent physical servers, server clusters or distributed systems composed of multiple physical servers.

[0068] Optionally, the identifier generator generates candidate identifiers by including the following steps:

[0069] Based on the time of receiving the generation request, determine the time generation element of the identifier;

[0070] The candidate identifier is generated based on the time generation element;

[0071] Based on the application scenario of the client, add auxiliary generation elements to the candidate identifier;

[0072] The auxiliary generation elements include, but are not limited to: random number generation elements, random string generation elements, ordered number generation elements, or ordered string generation elements.

[0073] Optionally, the step of performing legality and uniqueness checks on the candidate identifier using a validator includes:

[0074] When the identifier generator is deployed on a mobile terminal, and the candidate identifier is generated based on the device time of the mobile terminal, the verifier checks whether the time when the candidate identifier is received exceeds the allowed configurable time window to determine the legality verification result of the candidate identifier.

[0075] The verifier compares the received candidate identifier with the identifier stored in the registry center to determine whether the candidate identifier is duplicated with the identifier stored in the registry center, thereby determining the uniqueness verification result of the candidate identifier.

[0076] Optionally, storing the target identifiers that have passed the validity and uniqueness checks through the registration center includes:

[0077] Configure the forward and backward time windows of the registry center;

[0078] The time range for storable identifiers in the registry center is determined based on the forward time window and the backward time window.

[0079] Identifiers that are outside the specified time range will be logically or physically cleaned up.

[0080] The implementation methods of the registration center include, but are not limited to: data files, cache middleware that supports data persistence, or database tables.

[0081] Optionally, the step of logically or physically cleaning up identifiers that exceed the time range includes, but is not limited to:

[0082] The TTL function of the database management system is used to specify the lifespan of the identifier of the record. When the TTL of the identifier is exhausted, the record corresponding to the identifier is automatically deleted.

[0083] Alternatively, a garbage collector can be used, employing timed or event-triggered methods to reclaim invalid identifier records.

[0084] Optionally, the method further includes:

[0085] The storage time window of the registry center is dynamically configured, wherein the storage time window is used to represent the storage time of the identifiers stored in the registry center; the registry center stores identifier records for a period of time before and after the storage time.

[0086] The time window of the verifier is smaller than the storage time window of the registration center;

[0087] The time difference between the start time of the verifier's storage time window and the start time of the registration center's time window is greater than a first threshold.

[0088] The time difference between the end time of the registration center's time window and the end time of the verifier's storage time window is greater than the second threshold.

[0089] Another aspect of the present invention provides a unique identifier generation apparatus, comprising:

[0090] The first module is used to receive a request from the client to generate a unique identifier and to generate candidate identifiers.

[0091] The second module is used to perform legality and uniqueness checks on the candidate identifiers through a validator, and to determine the candidate identifiers that pass the legality and uniqueness checks as the target identifiers.

[0092] The third module is used to store target identifiers that have passed the validity and uniqueness checks through the registration center;

[0093] The fourth module is used to feed back the target identifier to the client.

[0094] Another aspect of this invention provides a system for generating unique identifiers, comprising:

[0095] The client is used to send requests for the generation of unique identifiers and to receive the generated target identifiers.

[0096] The identifier generator is used to generate candidate identifiers based on the unique identifier generation request sent by the client.

[0097] A validator is used to perform legality and uniqueness checks on the candidate identifiers, and to determine the candidate identifiers that pass the legality and uniqueness checks as the target identifiers.

[0098] The registry center is used to store target identifiers that have passed validity and uniqueness checks.

[0099] Another aspect of the present invention provides an electronic device, including a processor and a memory;

[0100] The memory is used to store programs;

[0101] The processor executes the program to implement the method described above.

[0102] This invention also discloses a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device can read the computer instructions from the computer-readable storage medium and execute the computer instructions, causing the computer device to perform the aforementioned method.

[0103] The specific implementation process of the present invention will now be described in detail with reference to the accompanying drawings:

[0104] like Figure 1 As shown, this invention mainly consists of three components: an identifier generator, a validator, and a registry center. These components can be combined in various ways, such as deploying the three components independently, merging them together, merging the generator and validator, or merging the validator and registry center. The functions and implementations of the components are described in detail below.

[0105] The identifier generator is primarily used to receive and respond to generation requests and to generate identifiers. The generation elements of an identifier include time and other optional factors. Time can be the time people see in daily life or time calculated from time, including but not limited to the following generation methods: 1) Common date and time, such as the 24-hour format (year, month, day, hour, minute, second), similar to 20220101120030, accurate to milliseconds, microseconds, nanoseconds, etc.; 2) Epoch time, i.e., the number of seconds that have elapsed since January 1, 1970, at 00:00:00, accurate to milliseconds, microseconds, nanoseconds, etc.; 3) Time calculated from time, such as the number of seconds that have elapsed since January 1, 2022, at 00:00:00, accurate to milliseconds, microseconds, nanoseconds, etc. Other optional factors are mainly used to control or assist in identifier generation. For example, when the probability of repetition of identifiers generated solely by the time factor is insufficient for the application scenario, other optional factors can instruct the generator to generate random numbers, random strings, ordered numbers, ordered strings, etc., and combine these characters with the time factor to form the final identifier. Other optional factors can also instruct the generator to stop attempting to generate a unique identifier after multiple failed attempts and inform the client of the reason for the failure.

[0106] The validator is primarily used to verify the legality and uniqueness of identifiers generated by the generator. Legality verification checks whether the generated identifier has expired. For example, in some application scenarios, the generator is located on a mobile device, and the generator's time factor value is specified to be derived from the mobile device's time. When the validator finds that the received identifier exceeds the allowed configurable time window, it determines the identifier as an invalid identifier. Uniqueness verification verifies that the identifier is globally unique. Since identifiers are generated based on time, it is only necessary to ensure that identifiers generated at the same time are not duplicated. Specifically, the complete identifiers, partial identifiers, or identifier descriptors generated at the same time can be stored in a registry center. The validator uses the registry center to determine whether identifiers are duplicated. When the validator finds an invalid or non-unique identifier, it instructs the generator to regenerate the identifier.

[0107] The registry center stores generated identifiers within a specified time window, such as records of identifiers generated between the current time minus 60 seconds and the current time plus 30 seconds. The length of the forward and backward windows can be set according to the actual application scenario. In scenarios with a low number of generated identifiers, the length can be appropriately increased; in scenarios with a high number of generated identifiers, the length can be appropriately decreased to avoid storing too many generated identifiers in the registry center, thus consuming excessive storage resources or affecting retrieval efficiency. The registry center can be implemented in different ways, such as a file, a cache middleware that supports data persistence, or a database table, etc., choosing the appropriate medium and data structure based on the specific application scenario. Furthermore, logical or physical cleanup of invalid or expired records in the registry center can be performed in various ways, including but not limited to the following: 1) Using the TTL (Time To Live) function of existing database management systems, such as Cassandra database, allowing a specified lifespan for records; when the TTL expires, the record becomes invalid. 2) Using a garbage collector, triggered periodically or by events, to reclaim records considered invalid.

[0108] Both the validator and the registry center contain their own configurable time windows. For the registry center, the time window serves two purposes: 1) Preventing excessive data volume. If the registry center stores all historically generated identifiers, it will become a bottleneck. The identifiers in this invention are time-based, ensuring the global uniqueness of new identifiers. Only the newly generated identifier needs to be compared with identifiers in the registry center that have the same time factor. To avoid consuming excessive storage and computing resources and to accelerate retrieval efficiency, the registry center can configure time windows as needed, selecting to retain only generated identifiers within a specified time period. 2) Improving fault tolerance. In practical applications, due to various reasons, the times of different system participants may be inconsistent, with some participants being faster or slower than the actual time. Therefore, it is necessary to allow for errors between the time in the identifiers and the actual time, allowing the registry center to store records generated before and after the current time for a certain duration. For the validator, the selection of the time window needs to be based on the registry center's time window configuration and should be included within the registry center's time window. This is because if the validator's window start time is earlier than the registry center's window start time, the identifier received by the validator may be an existing identifier that has been removed from the registry center, resulting in the generation of a globally non-unique identifier. If the validator's window expires later than the registry's window expires later, the identifiers received by the validator will not be stored in the registry, thus affecting the uniqueness determination of subsequently generated identifiers. Specifically, the relationship between the validator's storage time window and the registry's time window can be expressed as:

[0109] 1) The start time of the verifier's storage time window - the start time of the registration center's time window > the first threshold;

[0110] 2) The end time of the registration center's time window - the end time of the verifier's storage time window > the second threshold.

[0111] Furthermore, the start time of the validator's time window should not be too close to the start time of the registry's time window, nor should their end times be too close. Otherwise, network latency and time differences between the registry and the validator may affect the determination of global uniqueness. For example, the validator's forward and backward time intervals can be set to 50% of the registry's forward and backward time intervals.

[0112] In summary, compared with the prior art, this invention provides a method and apparatus for generating unique identifiers for data records, which can simultaneously ensure the following characteristics of the identifiers: 1) Global uniqueness, ensuring that no two records have duplicate identifiers; 2) Orderliness, the identifiers are generated in chronological order, which can speed up retrieval efficiency; 3) Unlimited generation quantity, which will not be exhausted; 4) Low computational resource consumption, the identifier composition is simple, and the generation algorithm is also simple; 5) Low storage resource consumption, the identifier length can be short enough while ensuring sufficient storage; 6) Flexible application, the components of the apparatus can be split and merged according to specific application scenarios to obtain the optimal generation scheme.

[0113] In some alternative embodiments, the functions / operations mentioned in the block diagrams may not occur in the order shown in the operation diagrams. For example, depending on the functions / operations involved, two consecutively shown blocks may actually be executed substantially simultaneously, or the blocks may sometimes be executed in reverse order. Furthermore, the embodiments presented and described in the flowcharts of this invention are provided by way of example to provide a more comprehensive understanding of the technology. The disclosed methods are not limited to the operations and logic flows presented herein. Alternative embodiments are contemplated in which the order of various operations is altered and sub-operations described as part of a larger operation are executed independently.

[0114] Furthermore, although the invention has been described in the context of functional modules, it should be understood that, unless otherwise stated, one or more of the described functions and / or features may be integrated into a single physical device and / or software module, or one or more functions and / or features may be implemented in a separate physical device or software module. It is also understood that a detailed discussion of the actual implementation of each module is unnecessary for understanding the invention. Rather, given the properties, functions, and internal relationships of the various functional modules in the apparatus disclosed herein, the actual implementation of the module will be understood within the scope of conventional skill of an engineer. Therefore, those skilled in the art can implement the invention as set forth in the claims using ordinary techniques without excessive experimentation. It is also understood that the specific concepts disclosed are merely illustrative and not intended to limit the scope of the invention, which is determined by the full scope of the appended claims and their equivalents.

[0115] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, essentially, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0116] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device.

[0117] More specific examples of computer-readable media (a non-exhaustive list) include: electrical connections (electronic devices) having one or more wires, portable computer disk drives (magnetic devices), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Furthermore, computer-readable media can even be paper or other suitable media on which the program can be printed, because the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in computer memory.

[0118] It should be understood that various parts of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.

[0119] In the description of this specification, references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.

[0120] Although embodiments of the invention have been shown and described, those skilled in the art will understand that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the claims and their equivalents.

[0121] The above is a detailed description of the preferred embodiments of the present invention, but the present invention is not limited to the embodiments described. Those skilled in the art can make various equivalent modifications or substitutions without departing from the spirit of the present invention, and these equivalent modifications or substitutions are all included within the scope defined by the claims of this application.

Claims

1. A method of generating a unique identifier, characterized by, The method comprises the following steps: receiving, by an identifier generator, a generation request of a unique identifier issued by a client, and generating a candidate identifier; checking, by a checker, the legality and uniqueness of the candidate identifier, and determining the candidate identifier that passes the legality and uniqueness check as a target identifier; storing, by a registration center, the target identifier that passes the legality and uniqueness check; feeding back the target identifier to the client; the deployment mode of the identifier generator, the checker and the registration center comprises: integrating the identifier generator, the checker and the registration center in the same terminal; or, deploying the identifier generator, the checker and the registration center to three different terminals respectively; or, deploying any two of the identifier generator, the checker and the registration center to a first terminal, and deploying the remaining one to a second terminal; wherein the terminal includes but is not limited to: a smart phone, a computer, a virtual machine, a container, a cloud server, a database management system, an intelligent voice interaction device, a smart home appliance, a vehicle terminal, an aircraft, a stand-alone physical server, a server cluster composed of multiple physical servers or a distributed system; the legality check of the candidate identifier by the checker comprises: when the identifier generator is deployed in a mobile terminal and the candidate identifier is generated based on the device time of the mobile terminal, checking, by the checker, whether the time of receiving the candidate identifier exceeds the allowed configurable time window to determine the legality check result of the candidate identifier; the storage of the target identifier that passes the legality and uniqueness check by the registration center comprises: configuring the forward time window and the backward time window of the registration center; determining the time range of the storable identifiers of the registration center according to the forward time window and the backward time window; logically or physically cleaning up the identifiers that exceed the time range; wherein the implementation mode of the registration center includes but is not limited to: a data file, a cache middleware supporting data persistence or a database table; the method further comprises: dynamically configuring the storage time window of the registration center, wherein the storage time window is used to represent the storage time of the identifiers stored in the registration center; the registration center stores the identifier records within a certain period of time before and after the storage time; the time window of the checker is smaller than the storage time window of the registration center; the time difference between the start time of the storage time window of the checker and the start time of the time window of the registration center is greater than a first threshold value; the time difference between the end time of the time window of the registration center and the end time of the storage time window of the checker is greater than a second threshold value.

2. The method of claim 1, wherein, The identifier generator generates a candidate identifier, which comprises the following steps: determining a time generation element of the identifier according to the receiving time of the generation request; generating the candidate identifier according to the time generation element. According to an application scenario in which the client is located, an auxiliary generation element is added to the candidate identifier; The auxiliary generation element includes, but is not limited to, a random number generation element, a random string generation element, an ordered number generation element, or an ordered string generation element.

3. The method of claim 1, wherein, The candidate identifier is subjected to uniqueness verification by a verifier, including: The verifier compares the received candidate identifier with identifiers stored in the registration center, determines whether the candidate identifier is duplicated with the identifiers stored in the registration center, and determines a uniqueness verification result of the candidate identifier.

4. The method of claim 1, wherein, The identifiers that exceed the time range are subjected to logical cleaning or physical cleaning, including but not limited to: A TTL function of a database management system is used to specify a life limit for a recorded identifier, and after the TTL of the identifier is exhausted, the record of the corresponding identifier is automatically deleted; Or, a garbage collector is used, and the collector recycles invalid identifier records in a time-triggered or event-triggered manner.

5. An apparatus for generating a unique identifier, the apparatus comprising: Including: A first module is configured to receive, by an identifier generator, a generation request of a unique identifier sent by a client, and generate a candidate identifier; A second module is configured to subject the candidate identifier to legality verification and uniqueness verification by a verifier, and determine the candidate identifier that passes the legality verification and the uniqueness verification as a target identifier; A third module is configured to store the target identifier that passes the legality verification and the uniqueness verification by a registration center; A fourth module is configured to feed back the target identifier to the client; The identifier generator, the verifier, and the registration center are deployed in the following manner: The identifier generator, the verifier, and the registration center are combined and deployed in the same terminal; Or, the identifier generator, the verifier, and the registration center are respectively deployed to three different terminals; Or, any two of the identifier generator, the verifier, and the registration center are deployed to a first terminal, and the remaining one is deployed to a second terminal; The terminal includes, but is not limited to, a smartphone, a computer, a virtual machine, a container, a cloud server, a database management system, an intelligent voice interaction device, a smart home appliance, a vehicle-mounted terminal, an aircraft, a standalone physical server, a server cluster composed of multiple physical servers, or a distributed system; The legality verification of the candidate identifier by the verifier includes: When the identifier generator is deployed on a mobile terminal, and the candidate identifier is generated based on the device time of the mobile terminal, the verifier verifies whether the time when the candidate identifier is received exceeds an allowed configurable time window, to determine a legality verification result of the candidate identifier; The storage of the target identifier that passes the legality verification and the uniqueness verification by the registration center includes: The forward time window and the backward time window of the registration center are configured; According to the forward time window and the backward time window, a time range of the storable identifiers of the registration center is determined; The identifiers that exceed the time range are subjected to logical cleaning or physical cleaning; The implementation mode of the registration center includes but is not limited to: a data file, cache middleware supporting data persistence, or a database table; Further comprising: The storage time window of the registration center is dynamically configured, wherein the storage time window is used to represent the storage time of the identifier stored in the registration center; the registration center stores the identifier record within a certain period of time before and after the storage time; The time window of the verifier is smaller than the storage time window of the registration center; The time difference between the start time of the storage time window of the verifier and the start time of the time window of the registration center is greater than a first threshold value; The time difference between the end time of the time window of the registration center and the end time of the storage time window of the verifier is greater than a second threshold value.

6. A system for generating a unique identifier, the system comprising: Comprising: A client for issuing a generation request of a unique identifier and receiving a generated target identifier; An identifier generator for generating a candidate identifier according to the generation request of the unique identifier issued by the client; A verifier for performing legality verification and uniqueness verification on the candidate identifier, and determining the candidate identifier that passes the legality verification and uniqueness verification as the target identifier; The legality verification on the candidate identifier includes: when the identifier generator is deployed on a mobile terminal and the candidate identifier is generated based on the device time of the mobile terminal, verifying whether the time of receiving the candidate identifier exceeds an allowed configurable time window to determine the legality verification result of the candidate identifier; A registration center for storing the target identifier that passes the legality verification and uniqueness verification; the storage of the target identifier that passes the legality verification and uniqueness verification includes: configuring a forward time window and a backward time window of the registration center; determining the time range of the storable identifier of the registration center according to the forward time window and the backward time window; logically or physically cleaning up the identifiers that exceed the time range; wherein the implementation mode of the registration center includes but is not limited to: a data file, cache middleware supporting data persistence, or a database table; The deployment mode of the identifier generator, the verifier, and the registration center includes: The identifier generator, the verifier, and the registration center are combined and deployed on the same terminal; Or, the identifier generator, the verifier, and the registration center are respectively deployed on three different terminals; Or, any two of the identifier generator, the verifier, and the registration center are deployed on a first terminal, and the remaining one is deployed on a second terminal; The terminal includes but is not limited to: a smartphone, a computer, a virtual machine, a container, a cloud server, a database management system, an intelligent voice interaction device, a smart home appliance, a vehicle-mounted terminal, an aircraft, a standalone physical server, a server cluster composed of multiple physical servers, or a distributed system; Further comprising: dynamically configure a storage time window of the registration center, wherein the storage time window is used to represent a storage time of the identifiers stored in the registration center; the registration center stores identifier records in a period of time before the storage time and a period of time after the storage time; a time window of the checker is less than a storage time window of the registration center; a time difference between a start time of the storage time window of the checker and a start time of the time window of the registration center is greater than a first threshold value; a time difference between an end time of the time window of the registration center and an end time of the storage time window of the checker is greater than a second threshold value.

7. An electronic device, comprising: comprise a processor and a memory; the memory is used to store a program; the processor executes the program to implement the method in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Creation method and system for document unique identifier, unique identifier creation management device, and program

    JP2005339134A