Service identifier generation method and device, computer equipment and storage medium
By dividing the business identifier into a business area, a self-increase factor area and a verification area, and using Redis services and exclusive OR operations, a business identifier with ambiguity and self-validation characteristics is solved, and the identification cannot be read in the prior art The problem of obtaining information has achieved the uniqueness of the identification and stable and efficient performance.
Patent Information
- Application Number
- CN202411620844.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-14
- Publication Date
- 2025-02-14
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the prior art, the identification generation scheme of a distributed system or multi-node system cannot read information from the generated identification, resulting in the identification losing meaning.
By dividing the business identifiers to be generated into a business area, a self-increase factor area and a verification area in bit mode, and using Redis service to realize self-increase factor calculation, combining XOR operation and verification data intercept, generate self-increase and self-increase and self-increase Service ID for verification characteristics.
The ambiguity of business identification is realized, and the service data, self-increase factor and verification data can be read from the identification, ensuring the uniqueness and security of the identification, avoiding the problems of ID duplication and poor performance.
Smart Images

Figure CN119449764A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a method, device, computer equipment and storage medium for generating a service identifier. Background Art
[0002] Identification (ID) generation is an essential function of computer systems. For a single system, ID generation is not a difficult task and can be achieved by using the self-incrementing ID method. However, for a distributed system or other multi-node system, the ID generation system becomes particularly important and even determines the success or failure of the system. Therefore, UUIDs calculated based on factors such as clock sequence and time value were designed, such as Figure 1 As shown in the figure. Its appearance seems to solve the problem of non-unique ID. When the user sends a request to the distributed application, each node of the distributed application is responsible for handling the ID problem separately. This method needs to call the UUID generation strategy to generate a globally unique ID to achieve the purpose of unique business ID.
[0003] Although this ID generation scheme is simple to operate, the ID itself will lose any meaning when using the UUID method. All that is shown to us is a bunch of characters. It will become impossible to read some information from the ID. Summary of the invention
[0004] The present invention aims to solve at least one of the technical problems existing in the prior art. To this end, the present invention proposes a service identifier generation method, device, computer equipment and storage medium to solve the technical problem that the identifier generated by the identifier generation scheme for a distributed system or other multi-node system cannot read information from it.
[0005] In a first aspect, the present invention provides a method for generating a service identifier, the method comprising: Dividing the service identifier to be generated into a plurality of intervals according to a bit mode and defining the size of each of the intervals, wherein the plurality of intervals at least include a service area, an auto-increment factor area and a check area; Defining service data according to the size of the defined service area, and calling a preset service to calculate an auto-increment factor according to the size of the defined auto-increment factor area; Calculate the verification data according to the business data, the self-increment factor and the defined size of the verification area; A service identifier is generated according to the service data, the self-increment factor and the verification data.
[0006] In the embodiment of the present application, the service identifier is divided by bit so that each part has a special meaning, thereby achieving the purpose of one code with multiple meanings.
[0007] In a technical solution of the above-mentioned method for generating a service identifier, defining the service data according to the size of the defined service area includes: According to the size of the defined service area, a service code corresponding to the current service is defined according to a preset rule to generate the service data.
[0008] In the embodiment of the present application, the service data in the service area is used to define the corresponding service codes for different services, thereby achieving the purpose of distinguishing the same services by using the service data in the service area.
[0009] In a technical solution of the above-mentioned service identifier generation method, the preset service includes a redis service, and the calling of the preset service to calculate the auto-increment factor according to the size of the defined auto-increment factor area includes: The redis service is called to generate auto-increment data, and the auto-increment factor is obtained based on the size of the auto-increment factor area and the auto-increment data.
[0010] In the embodiment of the present application, the self-increment of ID is realized by adopting the redis service. On the one hand, it avoids problems such as ID duplication caused by factors such as the release of self-incremented variables. On the other hand, since there is only one IO link request of Redis throughout the whole process, and based on the support of Redis and IO single thread, the performance is stable and efficient.
[0011] In a technical solution of the above-mentioned service identifier generation method, the auto-increment key for generating the auto-increment data includes the current time and the service data.
[0012] In a technical solution of the above-mentioned service identifier generation method, calling the redis service to generate self-increment data includes: Call the incr method of the redis service to generate auto-increment data.
[0013] In a technical solution of the above-mentioned service identifier generation method, the step of calculating the verification data according to the service data, the self-increment factor and the defined size of the verification area includes: Performing XOR calculation on the business data and the self-increment factor to obtain initial data; The initial data is intercepted based on the size of the verification area to obtain the verification data.
[0014] In the embodiment of the present application, a verification area is divided in the service identifier, so that the verification data in the verification area can be used to perform self-verification of the service identifier.
[0015] In a technical solution of the above-mentioned service identifier generation method, the service data, the self-increment factor and the verification data include binary data; The generating a service identifier according to the service data, the self-increment factor and the verification data includes: Convert the business data, the auto-increment factor and the verification data into intermediate identification data according to the high and low bits; The intermediate identification data is converted from binary to decimal to obtain the service identification.
[0016] In a second aspect, the present invention provides a service identifier generation device, the device comprising: An interval division module, used for dividing the service identifier to be generated into a plurality of intervals according to a bit mode and defining the size of each of the intervals, wherein the plurality of intervals at least include a service area, an auto-increment factor area and a check area; A first calculation module, used to define service data according to the size of the defined service area, and to call a preset service to calculate an auto-increment factor according to the size of the defined auto-increment factor area; A second calculation module, used for calculating verification data according to the business data, the auto-increment factor and the defined size of the verification area; An identification generation module is used to generate a service identification according to the service data, the self-increment factor and the verification data.
[0017] In a third aspect, the present invention provides a computer device comprising a memory and a processor, wherein the memory stores a computer program executable on the processor, and when the computer program is executed by the processor, the service identifier generation method as described in any one of the first aspects is implemented.
[0018] In a fourth aspect, the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, wherein when the computer program is executed, the service identifier generation method as described in any one of the first aspects is implemented.
[0019] The above one or more technical solutions of the present invention have at least one or more of the following beneficial effects: In the technical solution of the present invention, the service identifier to be generated is divided into multiple intervals in a bit manner and the size of each interval is defined, wherein the multiple intervals at least include a service area, an auto-increment factor area, and a check area; the service data is defined according to the size of the defined service area, and the preset service is called to calculate the auto-increment factor according to the size of the defined auto-increment factor area; the check data is calculated according to the service data, the auto-increment factor, and the size of the defined check area; the service identifier is generated according to the service data, the auto-increment factor, and the check data. The present application solution divides the service identifier in a bit manner so that each part has a special meaning, and uses the service data in the service area to define the corresponding service code for different services, thereby achieving the purpose of using the service data in the service area to distinguish the same service, using the auto-increment factor area to realize the auto-increment feature of the service identifier, and using the check area to realize the self-check feature of the service identifier, so as to achieve the purpose of one code with multiple meanings.
[0020] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The disclosure of the present invention will become more easily understood with reference to the accompanying drawings. It is easy for those skilled in the art to understand that these drawings are only for illustrative purposes and are not intended to limit the scope of protection of the present invention. In addition, similar numbers in the figures are used to represent similar components, among which:
[0022] Figure 1 It is a flow chart of generating business codes for a distributed system using a UUID method provided by the prior art; Figure 2 is a flow chart of a method for generating a service identifier provided in Example 1 of the present application; Figure 3 It is a schematic diagram of the definition of each interval in the service identifier generation method provided in Example 1 of the present application; Figure 4 It is a flowchart of the service identifier generation method provided in Example 2 of the present application; Figure 5 It is a structural diagram of the service identifier generation device provided in Example 3 of the present application.
[0023] Figure 6 It is a structural diagram of the computer device provided in Example 4 of the present application. DETAILED DESCRIPTION
[0024] Some embodiments of the present invention are described below with reference to the accompanying drawings. It should be understood by those skilled in the art that these embodiments are only used to explain the technical principles of the present invention and are not intended to limit the protection scope of the present invention.
[0025] As described in the background technology, the existing ID generation solutions for distributed systems or other multi-node systems are simple to operate. However, when using the UUID method, the ID itself will lose any meaning. What is presented to us is just a bunch of characters. It will become impossible to read some information from the ID.
[0026] Based on this, this application proposes a bit-based self-incrementing identification (ID) generation scheme, which uses a bit method to cut and shape a part of the bits as partitions to distinguish the business codes of different businesses to achieve the purpose of distinguishing the businesses. The self-increment of the identification (ID) is realized by adopting the Redis service, and the last part of the bits is cut to store the verification data to achieve the purpose of ID self-verification and ensure the security of the identification (ID).
[0027] Embodiment 1 Figure 2 is a flow chart of a method for generating a service identifier provided in the first embodiment of the present application. The method is applied to an aerosol supply system. Figure 2 As shown, the method comprises the following steps: Step 1: Divide the service identifier into multiple intervals and define the size of each interval.
[0028] Specifically, in the embodiment of the present application, the service identifier is converted into binary and divided into a plurality of different intervals, and different intervals represent different meanings. As a preferred example, in the embodiment of the present application, the service identifier is divided into three intervals, referring to Figure 3 As shown, the first interval is the business area, the second interval is the self-increment factor area, and the third interval is the verification area. Figure 3 As shown, the sizes of each interval of the service identifier that needs to be defined are the xyz values in the accompanying figure.
[0029] It is understandable that in the embodiment of the present application, the size of each interval is not specifically limited. During specific implementation, the size of each interval can be determined based on actual business conditions, which will not be elaborated here.
[0030] Step 2: Define business data according to the size of the defined business area.
[0031] Specifically, the size of the service area is related to the number of types of services that need to be undertaken. In some specific embodiments, the type of service is equal to 2 x For example, if the size of the business area is 2 (i.e. x=2), then you can define 22 For a business, assuming the size of the business area is 4 (i.e. x=4), we can define 2 4 Therefore, the size of the business area can be set according to actual business needs and is not specifically limited here.
[0032] In addition, since the binary data representation format is used in the process of generating the service identifier in the embodiment of the present application, the service code needs to be converted into binary data when defining the service data. For example, assuming that this embodiment needs to undertake 3 types of service codes, the size of the service area is 2 (ie x=2), and assuming that the service codes need to be numbered 1, 2, and 3 respectively, then the service area code corresponding to the first service code is 0, the service area code corresponding to the second service code is 1, and so on. However, since the service area has 2 bits (so the maximum number of services carried will not exceed 2 2 =4), the service area code corresponding to the second service can be defined as 01.
[0033] Step 3: Calculate the increment factor.
[0034] It is understandable that, in order to ensure the uniqueness of the business identifier (ID), the business identifier self-increment factor must be unique or unique for a period of time. There are many commonly used methods, such as using GUID or using algorithms to implement variable self-increment (such as memory variable self-increment). If the GUID method is used, the self-increment feature cannot be met; if the memory variable self-increment method is used, if the system maintenance causes the self-increment variable to be released, it will inevitably lead to catastrophic consequences such as duplication of the business identifier (ID). In response to the above problems, the embodiment of the present application adopts the redis self-increment method to implement this function, which can avoid problems such as ID duplication due to factors such as the release of self-increment variables. At the same time, since there is only one IO link request from Redis throughout the process, and based on the support of Redis and IO single thread, the performance is stable and efficient.
[0035] As a preferred embodiment, the self-increment key for generating self-increment data in the embodiment of the present application includes the current time and business data. In the specific implementation, the self-increment key (key) of redis is first defined. Exemplarily, the format of the self-increment key (key) can be business code + time. Such as 01240616, where 01 is the business code and 240616 is the date of June 16, 24. Secondly, the incr method of redis can be called to generate self-increment data (value) according to the self-increment key (key), such as: the self-increment data content obtained according to the self-increment key (key) is 0010. Finally, the time and the obtained self-increment data are spliced in order from high to low. For example: high bit: 240616, low bit: 0001. If the length of the self-increment factor is 28 bits, the high bit is converted into binary: 0011 1010 1011 1110 1000, and the low bit is converted into binary: 0010. After concatenation, the self-increment factor area is encoded as: 0011 1010 1011 1110 1000 0000 0010.
[0036] Step 4: Verify the data by XOR calculation based on the business data and the auto-increment factor.
[0037] In some specific embodiments, the verification data is obtained by performing an XOR operation on the service data and the self-increment factor. For example, assuming that the service data of the service area obtained in step 2 is: 01, and the self-increment factor obtained in step 3 is coded as: 0011 1010 1011 1110 1000 0000 0010, performing an XOR operation on the two results in: 0011 1010 10111110 1000 0000 0000 0011.
[0038] Furthermore, when obtaining the verification data, the size of the verification area needs to be used as a reference factor. For example, assuming that the size of the verification bit is 2 (i.e., z=2), as an exemplary and non-restrictive description, the lower two bits of the above result can be intercepted as verification data, that is, the final verification data is 11. It can be understood that the above-mentioned verification data interception method is only an exemplary and non-restrictive description, and does not constitute a specific limitation on the present application scheme. In other specific embodiments, the upper two bits of the calculation result or any two bits can also be intercepted as the final verification data, which are not listed here one by one.
[0039] Step 5: Convert the business data, auto-increment factor and verification data into the final business identifier according to the high and low bits.
[0040] As an illustrative but not restrictive explanation, in the embodiment of the present application, the business data, the self-increment factor and the check data can be spliced, and then the binary-decimal conversion is performed to obtain the final business identification. For example, assuming that the size of the business area is defined as 2, the size of the self-increment factor area is 28, and the size of the check area is 2, the business data, the self-increment factor and the check data calculated according to the above steps two to four are 01, 0011 1010 1011 1110 1000 00000010, 11 respectively, and the data obtained by splicing the three in order from high to low is 01 0011 1010 10111110 1000 0000 0010 11, and the data is converted from binary to decimal, and the final business identification is 1,320,132,619.
[0041] Embodiment 2 Corresponding to the above-mentioned embodiment 1, the present application also provides a method for generating a service identifier, which is particularly suitable for generating a service identifier in a distributed system or other multi-node system. In this embodiment, the same or similar contents as those in the above-mentioned embodiment 1 can be referred to the above introduction, and will not be described in detail later. Figure 4 As shown, the method comprises the following steps:
[0042] S100: Divide the service identifier to be generated into a plurality of intervals according to a bit mode and define the size of each of the intervals, wherein the plurality of intervals at least include a service area, an auto-increment factor area and a check area; Specifically, the service identifier is divided into bits so that each part has a special meaning. The service data in the service area is used to define the corresponding service codes for different services, thereby achieving the purpose of distinguishing the same services by using the service data in the service area, and the self-increment factor area is used to realize the self-increment feature of the service identifier. The check area is used to realize the self-check feature of the service identifier, so as to achieve the purpose of multiple meanings of one code.
[0043] It is understandable that the above division of the service identifier into the service area, the self-increment factor area and the check area in a bit manner is only an exemplary and non-restrictive description, and does not constitute a specific limitation on the present application scheme. Without violating the inventive concept of the present application, the user can also divide it in other ways. For example, in other specific embodiments, the user can also set other partitions to represent other meanings according to actual business needs.
[0044] It is understandable that in the embodiment of the present application, the size of each interval is not specifically limited. During specific implementation, the size of each interval can be determined based on actual business conditions, which will not be elaborated here.
[0045] S200: defining service data according to the size of the defined service area, and calling a preset service to calculate an auto-increment factor according to the size of the defined auto-increment factor area; It can be understood that the service identification method provided by the present application, on the one hand, defines the corresponding service codes for different services by utilizing the service data in the service area, thereby achieving the purpose of distinguishing the same services by utilizing the service data in the service area; on the other hand, realizes the self-increment characteristic of the service identification by utilizing the self-increment factor in the self-increment factor area.
[0046] S300: Calculate verification data according to the business data, the auto-increment factor and the defined size of the verification area; It should be noted that the above-mentioned method of calculating the verification data is only an exemplary and non-restrictive description. Without violating the inventive concept of the present application, users can also use other methods to generate verification data according to actual business needs, which will not be elaborated here.
[0047] S400: Generate a service identifier according to the service data, the self-increment factor and the verification data.
[0048] As a preferred implementation manner, in the embodiment of the present application, the defining of the service data according to the size of the defined service area includes: According to the size of the defined service area, a service code corresponding to the current service is defined according to a preset rule to generate the service data.
[0049] Specifically, the preset rules are not specifically limited in the embodiments of the present application. Without violating the inventive concept of the present application, the user can set the preset rules according to actual needs. For example, as an exemplary and non-restrictive description, the size of the service area can be associated with the number of types of services to be undertaken. For example, the type of service is equal to 2 x , where x is the size of the service area.
[0050] As mentioned above, since a binary data representation format is used in the process of generating a service identifier, the service code needs to be converted into binary data when defining service data. The specific conversion process does not belong to the protection content of the present invention and will not be repeated here.
[0051] As a preferred implementation, in an embodiment of the present application, the preset service includes a redis service, and the calling of the preset service to calculate the auto-increment factor according to the size of the defined auto-increment factor area includes: The redis service is called to generate auto-increment data, and the auto-increment factor is obtained based on the size of the auto-increment factor area and the auto-increment data.
[0052] Specifically, as mentioned above, based on the defects in the existing methods of implementing ID self-increment, in the embodiments of the present application, ID self-increment is implemented by adopting the redis service. On the one hand, it can avoid problems such as ID duplication due to factors such as the release of self-incremented variables. On the other hand, since there is only one IO link request in the whole process, Redis, and based on the support of Redis and IO single thread, the performance is stable and efficient.
[0053] As a preferred implementation, in an embodiment of the present application, the auto-increment key for generating the auto-increment data includes the current time and business data.
[0054] As a preferred implementation method, in the embodiment of the present application, calling the redis service to generate self-increment data includes: Call the incr method of the redis service to generate auto-increment data.
[0055] It is understandable that the Incr method of the Redis service increments the numeric value stored in the key by one. If the key does not exist, the key value will be initialized to 0 first, and then the INCR operation will be performed. If the value contains the wrong type, or the string type value cannot be represented as a number, an error will be returned. It should be noted that the value of this operation is limited to 64-bit signed numbers.
[0056] As a preferred implementation manner, in the embodiment of the present application, the verification data is calculated according to the business data, the self-increment factor and the defined size of the verification area, including: Performing XOR calculation on the business data and the self-increment factor to obtain initial data; The initial data is intercepted based on the size of the verification area to obtain the verification data.
[0057] It should be noted that the above-mentioned calculation method of the verification data is only an exemplary and non-restrictive description and does not constitute a specific limitation on the present application scheme.
[0058] It can be understood that, assuming that the size of the check area is z, when the initial data is intercepted based on the size of the check area to obtain the check data, it is necessary to intercept z bits of data as the check data. In specific implementation, the high z bits of the initial data can be intercepted as the check data, the low z bits of the initial data can be intercepted as the check data, or any z bits of the initial data can be intercepted as the check data, which will not be exhaustively listed here.
[0059] As a preferred implementation, in the embodiment of the present application, the business data, the self-increment factor and the verification data include binary data; The generating a service identifier according to the service data, the self-increment factor and the verification data includes: Convert the business data, the auto-increment factor and the verification data into intermediate identification data according to the high and low bits; The intermediate identification data is converted from binary to decimal to obtain the service identification.
[0060] It should be noted that the above conversion of business data, auto-increment factor and verification data into intermediate identification data according to high and low bits is only an exemplary and non-restrictive description. Without violating the inventive concept of the present application, other combinations can also be used to obtain intermediate identification data.
[0061] Embodiment 3 Corresponding to the above-mentioned embodiments 1 and 2, the present application further provides a service identifier generation device, which is used to implement the service identifier generation method provided in any one of embodiments 1 or 2. In this embodiment, the same or similar contents as those in the above-mentioned embodiments 1 or 2 can be referred to the above introduction and will not be described in detail later. Figure 5 As shown, the device comprises:
[0062] An interval division module 10, for dividing the service identifier to be generated into a plurality of intervals according to a bit mode and defining the size of each of the intervals, wherein the plurality of intervals at least include a service area, an auto-increment factor area and a check area; A first calculation module 20, configured to define service data according to the size of the defined service area, and to call a preset service to calculate an auto-increment factor according to the size of the defined auto-increment factor area; A second calculation module 30, configured to calculate verification data according to the business data, the auto-increment factor and the defined size of the verification area; The identifier generation module 40 is used to generate a service identifier according to the service data, the auto-increment factor and the verification data.
[0063] As a preferred implementation, in the embodiment of the present application, the first calculation module is specifically used for: According to the size of the defined service area, a service code corresponding to the current service is defined according to a preset rule to generate the service data.
[0064] As a preferred implementation, in the embodiment of the present application, the first calculation module is also used for: The redis service is called to generate auto-increment data, and the auto-increment factor is obtained based on the size of the auto-increment factor area and the auto-increment data.
[0065] As a preferred implementation, in an embodiment of the present application, the auto-increment key for generating the auto-increment data includes the current time and business data.
[0066] As a preferred implementation, in the embodiment of the present application, the first calculation module is also used for: Call the incr method of the redis service to generate auto-increment data.
[0067] As a preferred implementation, in the embodiment of the present application, the second calculation module is specifically used for: Performing XOR calculation on the business data and the self-increment factor to obtain initial data; The initial data is intercepted based on the size of the verification area to obtain the verification data.
[0068] As a preferred implementation, in the embodiment of the present application, the code generation module is specifically used for: The generating a service identifier according to the service data, the self-increment factor and the verification data includes: Convert the business data, the auto-increment factor and the verification data into intermediate identification data according to the high and low bits; Convert the intermediate identification data from binary to decimal to obtain the service identification Embodiment 4 Corresponding to the above-mentioned embodiment one or two, the present application also provides a computer device, including: a processor and a memory, the memory stores a computer program that can be run on the processor, and when the computer program is executed by the processor, the service identifier generation method provided in any one of the above-mentioned embodiments is executed.
[0069] in, Figure 6 The computer device 1500 is shown as an example, and may specifically include a processor 1510, a video display adapter 1511, a disk drive 1512, an input / output interface 1513, a network interface 1514, and a memory 1520. The processor 1510, the video display adapter 1511, the disk drive 1512, the input / output interface 1513, the network interface 1514, and the memory 1520 may be communicatively connected via a communication bus 1530.
[0070] Among them, the processor 1510 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, etc., to execute relevant programs to implement the technical solution provided by the present invention.
[0071] The memory 1520 can be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 1520 can store an operating system 1521 for controlling the operation of the electronic device and a basic input and output system (BIOS) for controlling the low-level operation of the electronic device. In addition, a web browser 1523, a data storage management system 1524, and a device identification information processing system 1525, etc. can also be stored. The above-mentioned device identification information processing system 1525 can be an application program that specifically implements the operations of the aforementioned steps in the embodiment of the present invention. In short, when the technical solution provided by the present invention is implemented by software or firmware, the relevant program code is stored in the memory 1520 and is called and executed by the processor 1510.
[0072] The input / output interface 1513 is used to connect the input / output module to realize information input and output. The input / output module can be configured in the device as a component (not shown in the figure), or it can be externally connected to the device to provide corresponding functions. The input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device may include a display, a speaker, a vibrator, an indicator light, etc.
[0073] The network interface 1514 is used to connect to a communication module (not shown) to achieve communication interaction between the device and other devices. The communication module can achieve communication through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).
[0074] The bus includes a path that transmits information between the various components of the device (eg, processor 1510 , video display adapter 1511 , disk drive 1512 , input / output interface 1513 , network interface 1514 , and memory 1520 ).
[0075] In addition, the electronic device can also obtain information on specific collection conditions from the virtual resource object collection condition information database for use in condition judgment, etc.
[0076] It should be noted that, although the above device only shows a processor 1510, a video display adapter 1511, a disk drive 1512, an input / output interface 1513, a network interface 1514, a memory 1520, a bus, etc., in the specific implementation process, the device may also include other components necessary for normal operation. In addition, it can be understood by those skilled in the art that the above device may also only include components necessary for implementing the solution of the present invention, and does not necessarily include all the components shown in the figure.
[0077] Embodiment 5 Corresponding to the above-mentioned embodiment one or two, the embodiment of the present application further provides a computer-readable storage medium, wherein, in this embodiment, the same or similar contents as those of the above-mentioned embodiment one or two can be referred to the above introduction and will not be repeated later.
[0078] The computer-readable storage medium stores a computer program, and when the computer program is executed by the processor, the service identifier generation method described above is implemented.
[0079] In some implementations, in the embodiments of the present application, when the computer program is executed by the processor, the steps corresponding to the method described in Embodiment 1 may also be implemented. Please refer to the detailed description in Embodiment 1 and no further details will be given here.
[0080] It can be known from the above description of the implementation mode that those skilled in the art can clearly understand that the present invention can be implemented by means of software plus a necessary general hardware platform. Based on such an understanding, the technical solution of the present invention can be essentially or partly contributed to the prior art in the form of a software product, which can be stored in a storage medium such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in the various embodiments of the present invention or certain parts of the embodiments.
[0081] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can refer to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system or system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can refer to the partial description of the method embodiment. The system and system embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without creative work.
[0082] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0083] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0084] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of the present invention, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0085] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present invention.
Claims
1. A method for generating a service identifier, characterized in that: The method comprises: Dividing the service identifier to be generated into a plurality of intervals according to a bit mode and defining the size of each of the intervals, wherein the plurality of intervals at least include a service area, an auto-increment factor area and a check area; Defining service data according to the size of the defined service area, and calling a preset service to calculate an auto-increment factor according to the size of the defined auto-increment factor area; Calculate the verification data according to the business data, the self-increment factor and the defined size of the verification area; A service identifier is generated according to the service data, the self-increment factor and the verification data.
2. The method for generating a service identifier according to claim 1, characterized in that: Defining the service data according to the size of the defined service area includes: According to the size of the defined service area, a service code corresponding to the current service is defined according to a preset rule to generate the service data.
3. The method for generating a service identifier according to any one of claims 1 or 2, characterized in that: The preset service includes a redis service, and the calling of the preset service to calculate the auto-increment factor according to the size of the defined auto-increment factor area includes: The redis service is called to generate auto-increment data, and the auto-increment factor is obtained based on the size of the auto-increment factor area and the auto-increment data.
4. The method for generating a service identifier according to claim 3, characterized in that: The auto-increment key for generating the auto-increment data includes the current time and business data.
5. The method for generating a service identifier according to claim 3, characterized in that: Calling the redis service to generate auto-increment data includes: Call the incr method of the redis service to generate auto-increment data.
6. The method for generating a service identifier according to any one of claims 1 or 2, characterized in that: The step of calculating the verification data according to the business data, the self-increment factor and the defined size of the verification area includes: Performing XOR calculation on the business data and the self-increment factor to obtain initial data; The initial data is intercepted based on the size of the verification area to obtain the verification data.
7. The method for generating a service identifier according to any one of claims 1 or 2, characterized in that: The business data, the auto-increment factor and the verification data include binary data; The generating a service identifier according to the service data, the self-increment factor and the verification data includes: Convert the business data, the auto-increment factor and the verification data into intermediate identification data according to the high and low bits; The intermediate identification data is converted from binary to decimal to obtain the service identification.
8. A service identifier generating device, characterized in that: The device comprises: An interval division module, used for dividing the service identifier to be generated into a plurality of intervals according to a bit mode and defining the size of each of the intervals, wherein the plurality of intervals at least include a service area, an auto-increment factor area and a check area; A first calculation module, used to define service data according to the size of the defined service area, and to call a preset service to calculate an auto-increment factor according to the size of the defined auto-increment factor area; A second calculation module, used for calculating verification data according to the business data, the auto-increment factor and the defined size of the verification area; The coding generation module is used to generate a service identifier according to the service data, the self-increment factor and the verification data.
9. A computer device, characterized in that: The invention comprises a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the computer program is executed by the processor, the service identifier generation method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium, wherein a computer program is stored in the computer-readable storage medium, characterized in that: When the computer program is executed, the service identifier generation method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Distributed unique ID generation method
CN106571953A
Method for generating and using distributed unique ID
CN108322222A
Distributed global ID generation method, device and equipment, and storage medium
CN108959386A
Unique identification method for distributed system
CN110704395A
Resource identifier generation method and device, equipment and storage medium
CN113553518A