CN109933574A - A kind of unique key generation method, device and terminal device - Google Patents
A kind of unique key generation method, device and terminal device Download PDFInfo
- Publication number
- CN109933574A CN109933574A CN201910146713.1A CN201910146713A CN109933574A CN 109933574 A CN109933574 A CN 109933574A CN 201910146713 A CN201910146713 A CN 201910146713A CN 109933574 A CN109933574 A CN 109933574A
- Authority
- CN
- China
- Prior art keywords
- sequence number
- unique key
- generated
- generation
- data
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Abstract
The present invention is suitable for distributed system technical field, provide a kind of unique key generation method, device and terminal device, wherein, method includes: to obtain data to be generated, Service Instance coding is generated according to the Service Instance of the data to be generated sequence is corresponding, according to real time in corresponding generation year, week, all several and seconds, formation sequence number, extension bits and version are corresponded to according to preset rules, above-mentioned generation field is synthesized into unique key according to unique key basic data structure, and the unique key is labeled in the data to be generated;Wherein, the generation field includes Service Instance coding, year, week, all several and seconds, sequence number, extension bits and version.Present invention can ensure that unique key data does not repeat under single machine scene, and meet distributed globally unique, order, can the primary demands such as counter solution property, high-performance, expansivity, readability.
Description
Technical field
The invention belongs to distributed system technical fields more particularly to a kind of unique key generation method, device and terminal to set
It is standby.
Background technique
Under distributed environment, generate unique key processing mode generally by Universally Unique Identifier (UUID,
Universally Unique Identifier) computation rule or database generating mode realize.
Wherein, 1, UUID computation rule ensure that the uniqueness of global system, but UUID has that generate performance poor, no
It is traceable, counter can not solve and randomness etc., if UUID will lead to database write-in problem as database key.
2, database mode is realized and is generally realized by data generation major key and the specific major key step-length of setting, such
Implementation performance is poor, ability extending transversely is poor, while depending on database, increases personnel's maintenance cost.
Unique key is generated by both the above scheme, there can be above-mentioned various problems.In fast development, require high-performance
Distributed environment under, user demand can not be able to satisfy.
Summary of the invention
In view of this, the embodiment of the invention provides a kind of unique key generation method, device and terminal device, it is existing to solve
There is the problem of technology.
The first aspect of the embodiment of the present invention provides a kind of unique key generation method, comprising:
Obtain data to be generated;
Service Instance coding is generated according to the Service Instance of the data to be generated sequence is corresponding;
According to real time in corresponding generation year, week, all several and seconds;
Formation sequence number, extension bits and version are corresponded to according to preset rules;
Above-mentioned generation field is synthesized into unique key according to unique key basic data structure, and the unique key is labeled in institute
It states in data to be generated;Wherein, the generation field includes Service Instance coding, year, week, all several and second, sequence number, extension bits
And version.
Optionally, the preset rules, comprising:
The sequence number is generated according to preset order, wherein preset order includes in such a way that high-performance is locked each
Cumulative serial number data in service;
It is a wheel with preset time period if it is different from the last sequence number generation time that current sequence number generates the time
It returns, the sequence number is generated since 0000, until formation sequence number 9999;
If the use of Present cycle time finishes, next circulation is waited, continues to generate the sequence number.
Optionally, the preset rules, further includes:
If the number of seconds that sequence number generates is identical as the number of seconds that last sequence number generates, serial number data adds 1;
If serial number data reaches maximum value, next circulation is waited;
If next circulation time reaches, continue formation sequence number since 0000.
Optionally, the preset rules, further includes:
Extension bits default value is 0;
If the Service Instance coding, the year, either field needs to extend in the sequence number, the value of extension bits adds
One, and by the version value of corresponding modification come the corresponding field of specified extension.
Optionally, the preset rules, further includes:
When version default value is 6, indicate that extension bits are 0;
Version value is 7, indicates the extension of Service Instance code field;
Version value is 8, indicates year field extension;
Version value is 9, indicates sequence-number field extension;Wherein, version value 0-5 is reserved place.
Optionally, according to real time in corresponding generation year, week, all several and seconds, comprising:
The second is generated since 00000 within daily first second, number of seconds is refreshed according to the variation of timing node automatically, it is per second to add automatically
1, until number of seconds be 86400, restart count the second;
If number of seconds adds 1 when the day before yesterday is identical as the next second date of arrival;
If resetting number of seconds when the day before yesterday and the next second date of arrival be not identical, the second is generated since 00000.
The second aspect of the embodiment of the present invention provides a kind of unique key generating means, comprising:
Module is obtained, for obtaining data to be generated;
First generation module is compiled for the corresponding Service Instance that generates of Service Instance sequence according to the data to be generated
Code;
Second generation module, for according to real time in corresponding generation year, week, all several and seconds;
Third generation module, for corresponding to formation sequence number, extension bits and version according to preset rules;
Synthesis module, for above-mentioned generation field to be synthesized unique key according to unique key basic data structure, and will be described
Unique key is labeled in the data to be generated;Wherein, the generation field include Service Instance coding, year, week, week it is several and
Second, sequence number, extension bits and version.
The third aspect of the embodiment of the present invention provides a kind of terminal device, comprising: memory, processor and is stored in
In the memory and the computer program that can run on the processor, when the processor executes the computer program
It realizes such as the step of the above method.
The fourth aspect of the embodiment of the present invention provides a kind of computer readable storage medium, the computer-readable storage
Media storage has computer program, realizes when the computer program is executed by processor such as the step of the above method.
The embodiment of the present invention is encoded according to the corresponding Service Instance that generates of Service Instance sequence of data to be generated, according to reality
Time in corresponding generation year, week, all several and seconds, formation sequence number, extension bits and version then are corresponded to according to preset rules, it will be above-mentioned
It generates field and unique key is synthesized according to unique key basic data structure, and unique key is labeled in data to be generated, Ke Yibao
Unique key data does not repeat under card single machine scene, and meet distributed globally unique, order, can counter solution property, high-performance, can
The primary demands such as dilatancy, readability.
Detailed description of the invention
It to describe the technical solutions in the embodiments of the present invention more clearly, below will be to embodiment or description of the prior art
Needed in attached drawing be briefly described, it should be apparent that, the accompanying drawings in the following description is only of the invention some
Embodiment for those of ordinary skill in the art without any creative labor, can also be according to these
Attached drawing obtains other attached drawings.
Fig. 1 is the flow diagram for the unique key generation method that the embodiment of the present invention one provides;
Fig. 2 is the structural schematic diagram of unique key generating means provided by Embodiment 2 of the present invention;
Fig. 3 is the schematic diagram for the terminal device that the embodiment of the present invention three provides.
Specific embodiment
In order to enable those skilled in the art to better understand the solution of the present invention, below in conjunction in the embodiment of the present invention
Attached drawing, technical solution in the embodiment of the present invention are explicitly described, it is clear that described embodiment is the present invention one
The embodiment divided, instead of all the embodiments.Based on the embodiments of the present invention, those of ordinary skill in the art are not doing
Every other embodiment obtained under the premise of creative work out, should fall within the scope of the present invention.
Description and claims of this specification and term " includes " and their any deformations in above-mentioned attached drawing, meaning
Figure, which is to cover, non-exclusive includes.Such as process, method or system comprising a series of steps or units, product or equipment do not have
It is defined in listed step or unit, but optionally further comprising the step of not listing or unit, or optionally also wrap
Include the other step or units intrinsic for these process, methods, product or equipment.In addition, term " first ", " second " and
" third " etc. is for distinguishing different objects, not for description particular order.
In order to illustrate technical solutions according to the invention, the following is a description of specific embodiments.
Embodiment one
As shown in Figure 1, the present embodiment provides a kind of unique key generation method, this method can be applied to as PC plate electricity
The terminal devices such as brain, mobile phone.Unique key generation method provided by the present embodiment, comprising:
S101, data to be generated are obtained.
In a particular application, obtain need to generate in the operation system of distributed system software global uniqueness major key to
Generate data, wherein uniqueness major key, abbreviation unique key, for summarizing data, dividing data, tracking data source, realization point
Library facility and divide table function.
S102, it is encoded according to the corresponding Service Instance that generates of Service Instance sequence of the data to be generated.
In a particular application, corresponding Service Instance is sequentially generated according to the Service Instance of data to be generated to encode, wherein
Service Instance sequence may be set to realize the sequence of configuration mode, configure corresponding Service Instance sequence in production environment.Service
Example code default is maximum to support 899 Service Instances, and reserved No. 1-99 is encoded to testing service coding.
S103, generation year, week, all several and seconds are corresponded to according to the real time.
In a particular application, the real time for obtaining current time generates corresponding year field, all words according to the real time
Section, week a few fields and second field support 00-99 specifically, year field defaults the rear two bits in time in the value real time
100 numerical value selections in total can extend year field and default value to support 000-999 according to version and extension bits co- controlling
Year, 1000 numerical value selections in total.Week is all numbers in 1 year locating in the real time, i.e., which week in 1 year.Week is several
For the range in place week, default value is between 0-6, and 0 is Sunday, and 1 is Monday, and so on the second be number of seconds where one day,
It changes over time and changes, specifically, the second generates since 00000, number of seconds is refreshed according to timing node automatically, it is per second to add automatically
1, until 86400.
S104, formation sequence number, extension bits and version are corresponded to according to preset rules.
In a particular application, corresponding sequence-number field, Extension Bit field and version field are generated according to preset rules,
In, the sequence number that Serial No. is generated according to preset order, preset order includes in such a way that high-performance is locked in each service
Interior cumulative serial number data.Extension bits are reserved place, default value 0.Version is that may specify the field of extension, when default value is 6
Indicate that extension bits do not work.Preset rules include:
If 1, the current sequence number generation time is different from the last sequence number generation time, with preset time period for one
Circulation, the formation sequence number since 0000, until formation sequence number 9999;
If the use of Present cycle time finishes, next circulation is waited, continues formation sequence number.Wherein, preset time period
It can be set, for example, setting the circulation time as 1S, then be generated since 0000 with 1S for a circulation as the case may be
Sequence number, until formation sequence number 9999 waits next circulation (next if Present cycle time (i.e. 1S) use finishes
Second), continue formation sequence number.
If 2, the number of seconds that sequence number generates is identical as the number of seconds that last sequence number generates, serial number data adds 1;
If serial number data reaches maximum value, next circulation is waited;
If next circulation time reaches, continue formation sequence number since 0000.
For example, if the description of this sequence number 2001 generation is identical as the description that last sequence number 2001 generates, this
Secondary sequence number 2001+1.If formation sequence number 9999, next second is waited, if next second reaches, is continued since 0000
Formation sequence number.
If 3, Service Instance coding, year, either field needs to extend in sequence number, the value of extension bits adds one, and passes through
The version value of corresponding modification extends corresponding field to specify.For example, if Service Instance coding, year, the year field in sequence number
It needs to extend, then extension bits add one, and revision value is 8, indicate to formulate extension year field.
4, version value 7 indicate the extension of Service Instance code field;
Version value is 8, indicates year field extension;
Version value is 9, indicates sequence-number field extension;Wherein, version value 0-5 is reserved place.
S105, above-mentioned generation field is synthesized into unique key according to unique key basic data structure, and by the unique alternate key
Note is in the data to be generated;Wherein, the generation field include Service Instance coding, year, week, all several and seconds, sequence number,
Extension bits and version.
In a particular application, above-mentioned generation field is synthesized into unique key according to unique key basic data structure, and will be unique
Key is labeled in data to be generated;Wherein, generating field includes Service Instance coding, year, week, all several and second, sequence number, extension
Position and version.
Unique key basic data structure is as shown in table 1:
In one embodiment, the preset rules, comprising:
The sequence number is generated according to preset order, wherein preset order includes in such a way that high-performance is locked each
Cumulative serial number data in service;
It is a wheel with preset time period if it is different from the last sequence number generation time that current sequence number generates the time
It returns, the sequence number is generated since 0000, until formation sequence number 9999;
If the use of Present cycle time finishes, next circulation is waited, continues to generate the sequence number.
In a particular application, according to preset order formation sequence number, wherein preset order includes the side locked by high-performance
Formula cumulative serial number data in each service, if the current sequence number generation time is different from the last sequence number generation time,
Then with preset time period for a circulation, the formation sequence number since 0000, until formation sequence number 9999, if when Present cycle
Between using finishing, then wait next circulation, continue formation sequence number.It is then a wheel with 1S for example, setting the circulation time as 1S
It returns, the formation sequence number since 0000, until formation sequence number 9999, if Present cycle time (i.e. 1S) use finishes, etc.
To next circulation (next second), continue formation sequence number.
In one embodiment, the preset rules, further includes:
If the number of seconds that sequence number generates is identical as the number of seconds that last sequence number generates, serial number data adds 1;
If serial number data reaches maximum value, next circulation is waited;
If next circulation time reaches, continue formation sequence number since 0000.
In a particular application, for example, if what the description that this sequence number 2001 generates was generated with last sequence number 2001
Identical, then this sequence number 2001+1 is described.If formation sequence number 9999, next second is waited, if next second reaches, from
0000 starts to continue formation sequence number.
In one embodiment, the preset rules, further includes:
Extension bits default value is 0;
If the Service Instance coding, the year, either field needs to extend in the sequence number, the value of extension bits adds
One, and by the version value of corresponding modification come the corresponding field of specified extension.
In a particular application, for example, if Service Instance coding, year, the year field in sequence number need to extend, extension bits
Add one (i.e. Service Instance coding becomes 1), revision value is 8, indicates to formulate extension year field.
In one embodiment, the preset rules, further includes:
When version default value is 6, indicate that extension bits are 0;
Version value is 7, indicates the extension of Service Instance code field;
Version value is 8, indicates year field extension;
Version value is 9, indicates sequence-number field extension;Wherein, version value 0-5 is reserved place.
In a particular application, when version default value is 6, indicate that extension bits are 0, version value 7 indicates Service Instance coding
Field extension, version value 8 indicate that year field extension, version value 9 indicate sequence-number field extension;Wherein, version value 0-5
For reserved place, do not handle temporarily.
In one embodiment, according to real time in corresponding generation year, week, all several and seconds, comprising:
The second is generated since 00000 within daily first second, number of seconds is refreshed according to the variation of timing node automatically, it is per second to add automatically
1, until number of seconds be 86400, restart count the second;
If number of seconds adds 1 when the day before yesterday is identical as the next second date of arrival;
If resetting number of seconds when the day before yesterday and the next second date of arrival be not identical, the second is generated since 00000.
In a particular application, the second is generated since 00000 within daily first second, the second is refreshed according to the variation of timing node automatically
Number, it is per second automatic plus 1, until number of seconds was 86400 (24*60*60 seconds in i.e. one day), restart to count the second, if when the day before yesterday and
The next second date of arrival is identical, then number of seconds adds 1, if resetting number of seconds when the day before yesterday and the next second date of arrival be not identical, opening from 00000
Begin to generate the second.For example, the day of next second 8640 is 1 if the day of current number of seconds 86399 is 1, then current number of seconds adds one (i.e.
For 86399+1).If 86399 corresponding days fields of current number of seconds are 1,86400 corresponding days next seconds field is 2, then weighs
Number of seconds is set, the second is generated since 00000.
The present embodiment generates Service Instance coding by the way that the Service Instance sequence according to data to be generated is corresponding, according to reality
Time in corresponding generation year, week, all several and seconds, formation sequence number, extension bits and version then are corresponded to according to preset rules, it will be above-mentioned
It generates field and unique key is synthesized according to unique key basic data structure, and unique key is labeled in data to be generated, Ke Yibao
Unique key data does not repeat under card single machine scene, and meet distributed globally unique, order, can counter solution property, high-performance, can
The primary demands such as dilatancy, readability.
It should be understood that the size of the serial number of each step is not meant that the order of the execution order in above-described embodiment, each process
Execution sequence should be determined by its function and internal logic, the implementation process without coping with the embodiment of the present invention constitutes any limit
It is fixed.
Embodiment two
As shown in Fig. 2, the present embodiment provides a kind of unique key generating means 100, for executing the method in embodiment one
Step.Unique key generating means 100 provided in this embodiment, comprising:
Module 101 is obtained, for obtaining data to be generated;
First generation module 102, for the corresponding generation Service Instance of Service Instance sequence according to the data to be generated
Coding;
Second generation module 103, for according to real time in corresponding generation year, week, all several and seconds;
Third generation module 104, for corresponding to formation sequence number, extension bits and version according to preset rules;
Synthesis module 105, for above-mentioned generation field to be synthesized unique key according to unique key basic data structure, and by institute
Unique key is stated to be labeled in the data to be generated;Wherein, the generation field include Service Instance coding, year, week, week it is several and
Second, sequence number, extension bits and version.
In one embodiment, the preset rules, comprising:
The sequence number is generated according to preset order, wherein preset order includes in such a way that high-performance is locked each
Cumulative serial number data in service;
It is a wheel with preset time period if it is different from the last sequence number generation time that current sequence number generates the time
It returns, the sequence number is generated since 0000, until formation sequence number 9999;
If the use of Present cycle time finishes, next circulation is waited, continues to generate the sequence number.
In one embodiment, the preset rules, further includes:
If the number of seconds that sequence number generates is identical as the number of seconds that last sequence number generates, serial number data adds 1;
If serial number data reaches maximum value, next circulation is waited;
If next circulation time reaches, continue formation sequence number since 0000.
In one embodiment, the preset rules, further includes:
Extension bits default value is 0;
If the Service Instance coding, the year, either field needs to extend in the sequence number, the value of extension bits adds
One, and by the version value of corresponding modification come the corresponding field of specified extension.
In one embodiment, the preset rules, further includes:
When version default value is 6, indicate that extension bits are 0;
Version value is 7, indicates the extension of Service Instance code field;
Version value is 8, indicates year field extension;
Version value is 9, indicates sequence-number field extension;Wherein, version value 0-5 is reserved place.
In one embodiment, according to real time in corresponding generation year, week, all several and seconds, comprising:
The second is generated since 00000 within daily first second, number of seconds is refreshed according to the variation of timing node automatically, it is per second to add automatically
1, until number of seconds be 86400, restart count the second;
If number of seconds adds 1 when the day before yesterday is identical as the next second date of arrival;
If resetting number of seconds when the day before yesterday and the next second date of arrival be not identical, the second is generated since 00000.
The present embodiment generates Service Instance coding by the way that the Service Instance sequence according to data to be generated is corresponding, according to reality
Time in corresponding generation year, week, all several and seconds, formation sequence number, extension bits and version then are corresponded to according to preset rules, it will be above-mentioned
It generates field and unique key is synthesized according to unique key basic data structure, and unique key is labeled in data to be generated, Ke Yibao
Unique key data does not repeat under card single machine scene, and meet distributed globally unique, order, can counter solution property, high-performance, can
The primary demands such as dilatancy, readability.
Embodiment three
Fig. 3 is the schematic diagram for the terminal device that one embodiment of the invention provides.As shown in figure 3, the terminal of the embodiment is set
Standby 3 include: processor 30, memory 31 and are stored in the meter that can be run in the memory 31 and on the processor 30
Calculation machine program 32, such as unique key generate program.The processor 30 is realized above-mentioned each when executing the computer program 32
Step in unique key generation method embodiment, such as step S101 to S105 shown in FIG. 1.Alternatively, the processor 30 is held
The function of each module/unit in above-mentioned each Installation practice, such as module shown in Fig. 2 are realized when the row computer program 32
101 to 105 function.
Illustratively, the computer program 32 can be divided into one or more module/units, it is one or
Multiple module/units are stored in the memory 31, and are executed by the processor 30, to complete the present invention.Described one
A or multiple module/units can be the series of computation machine program instruction section that can complete specific function, which is used for
Implementation procedure of the computer program 32 in the terminal device 3 is described.For example, the computer program 32 can be divided
It is cut into and obtains module, the first generation module, the second generation module, third generation module and synthesis module, each module concrete function
It is as follows:
Module is obtained, for obtaining data to be generated;
First generation module is compiled for the corresponding Service Instance that generates of Service Instance sequence according to the data to be generated
Code;
Second generation module, for according to real time in corresponding generation year, week, all several and seconds;
Third generation module, for corresponding to formation sequence number, extension bits and version according to preset rules;
Synthesis module, for above-mentioned generation field to be synthesized unique key according to unique key basic data structure, and will be described
Unique key is labeled in the data to be generated;Wherein, the generation field include Service Instance coding, year, week, week it is several and
Second, sequence number, extension bits and version.
The terminal device 3 can be the calculating such as desktop PC, notebook, palm PC and cloud server and set
It is standby.The terminal device may include, but be not limited only to, processor 30, memory 31.It will be understood by those skilled in the art that Fig. 3
The only example of terminal device 3 does not constitute the restriction to terminal device 3, may include than illustrating more or fewer portions
Part perhaps combines certain components or different components, such as the terminal device can also include input-output equipment, net
Network access device, bus etc..
Alleged processor 30 can be central processing unit (Central Processing Unit, CPU), can also be
Other general processors, digital signal processor (Digital Signal Processor, DSP), specific integrated circuit
(Application Specific Integrated Circuit, ASIC), ready-made programmable gate array (Field-
Programmable Gate Array, FPGA) either other programmable logic device, discrete gate or transistor logic,
Discrete hardware components etc..General processor can be microprocessor or the processor is also possible to any conventional processor
Deng.
The memory 31 can be the internal storage unit of the terminal device 3, such as the hard disk or interior of terminal device 3
It deposits.The memory 31 is also possible to the External memory equipment of the terminal device 3, such as be equipped on the terminal device 3
Plug-in type hard disk, intelligent memory card (Smart Media Card, SMC), safe digital card (Secure Digital, SD) dodge
Deposit card (Flash Card) etc..Further, the memory 31 can also both include the storage inside list of the terminal device 3
Member also includes External memory equipment.The memory 31 is for storing needed for the computer program and the terminal device
Other programs and data.The memory 31 can be also used for temporarily storing the data that has exported or will export.
It is apparent to those skilled in the art that for convenience of description and succinctly, only with above-mentioned each function
Can unit, module division progress for example, in practical application, can according to need and by above-mentioned function distribution by different
Functional unit, module are completed, i.e., the internal structure of described device is divided into different functional unit or module, more than completing
The all or part of function of description.Each functional unit in embodiment, module can integrate in one processing unit, can also
To be that each unit physically exists alone, can also be integrated in one unit with two or more units, it is above-mentioned integrated
Unit both can take the form of hardware realization, can also realize in the form of software functional units.In addition, each function list
Member, the specific name of module are also only for convenience of distinguishing each other, the protection scope being not intended to limit this application.Above system
The specific work process of middle unit, module, can refer to corresponding processes in the foregoing method embodiment, and details are not described herein.
In the above-described embodiments, it all emphasizes particularly on different fields to the description of each embodiment, is not described in detail or remembers in some embodiment
The part of load may refer to the associated description of other embodiments.
Those of ordinary skill in the art may be aware that list described in conjunction with the examples disclosed in the embodiments of the present disclosure
Member and algorithm steps can be realized with the combination of electronic hardware or computer software and electronic hardware.These functions are actually
It is implemented in hardware or software, the specific application and design constraint depending on technical solution.Professional technician
Each specific application can be used different methods to achieve the described function, but this realization is it is not considered that exceed
The scope of the present invention.
In embodiment provided by the present invention, it should be understood that disclosed device/terminal device and method, it can be with
It realizes by another way.For example, device described above/terminal device embodiment is only schematical, for example, institute
The division of module or unit is stated, only a kind of logical function partition, there may be another division manner in actual implementation, such as
Multiple units or components can be combined or can be integrated into another system, or some features can be ignored or not executed.Separately
A bit, shown or discussed mutual coupling or direct-coupling or communication connection can be through some interfaces, device
Or the INDIRECT COUPLING or communication connection of unit, it can be electrical property, mechanical or other forms.
The unit as illustrated by the separation member may or may not be physically separated, aobvious as unit
The component shown may or may not be physical unit, it can and it is in one place, or may be distributed over multiple
In network unit.It can select some or all of unit therein according to the actual needs to realize the mesh of this embodiment scheme
's.
It, can also be in addition, the functional units in various embodiments of the present invention may be integrated into one processing unit
It is that each unit physically exists alone, can also be integrated in one unit with two or more units.Above-mentioned integrated list
Member both can take the form of hardware realization, can also realize in the form of software functional units.
If the integrated module/unit be realized in the form of SFU software functional unit and as independent product sale or
In use, can store in a computer readable storage medium.Based on this understanding, the present invention realizes above-mentioned implementation
All or part of the process in example method, can also instruct relevant hardware to complete, the meter by computer program
Calculation machine program can be stored in a computer readable storage medium, the computer program when being executed by processor, it can be achieved that on
The step of stating each embodiment of the method.Wherein, the computer program includes computer program code, the computer program generation
Code can be source code form, object identification code form, executable file or certain intermediate forms etc..The computer-readable medium
It may include: any entity or device, recording medium, USB flash disk, mobile hard disk, magnetic that can carry the computer program code
Dish, CD, computer storage, read-only memory (ROM, Read-Only Memory), random access memory (RAM,
Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium etc..It should be noted that described
The content that computer-readable medium includes can carry out increasing appropriate according to the requirement made laws in jurisdiction with patent practice
Subtract, such as does not include electric carrier signal and electricity according to legislation and patent practice, computer-readable medium in certain jurisdictions
Believe signal.
Embodiment described above is merely illustrative of the technical solution of the present invention, rather than its limitations;Although referring to aforementioned reality
Applying example, invention is explained in detail, those skilled in the art should understand that: it still can be to aforementioned each
Technical solution documented by embodiment is modified or equivalent replacement of some of the technical features;And these are modified
Or replacement, the spirit and scope for technical solution of various embodiments of the present invention that it does not separate the essence of the corresponding technical solution should all
It is included within protection scope of the present invention.
Claims (10)
1. a kind of unique key generation method characterized by comprising
Obtain data to be generated;
Service Instance coding is generated according to the Service Instance of the data to be generated sequence is corresponding;
According to real time in corresponding generation year, week, all several and seconds;
Formation sequence number, extension bits and version are corresponded to according to preset rules;
Above-mentioned generation field is synthesized into unique key according to unique key basic data structure, and by the unique key be labeled in it is described to
It generates in data;Wherein, the generation field includes Service Instance coding, year, week, all several and seconds, sequence number, extension bits and version
This.
2. unique key generation method as described in claim 1, which is characterized in that the preset rules, comprising:
The sequence number is generated according to preset order, wherein preset order includes in such a way that high-performance is locked in each service
Interior cumulative serial number data;
If it is different from the last sequence number generation time that current sequence number generates the time, with preset time period for a circulation,
The sequence number is generated since 0000, until formation sequence number 9999;
If the use of Present cycle time finishes, next circulation is waited, continues to generate the sequence number.
3. unique key generation method as claimed in claim 2, which is characterized in that the preset rules, further includes:
If the number of seconds that sequence number generates is identical as the number of seconds that last sequence number generates, serial number data adds 1;
If serial number data reaches maximum value, next circulation is waited;
If next circulation time reaches, continue formation sequence number since 0000.
4. unique key generation method as described in claim 1, which is characterized in that the preset rules, further includes:
Extension bits default value is 0;
If the Service Instance coding, the year, either field needs to extend in the sequence number, the value of extension bits adds one,
And by the version value of corresponding modification come the corresponding field of specified extension.
5. unique key generation method as described in claim 1, which is characterized in that the preset rules, further includes:
When version default value is 6, indicate that extension bits are 0;
Version value is 7, indicates the extension of Service Instance code field;
Version value is 8, indicates year field extension;
Version value is 9, indicates sequence-number field extension;Wherein, version value 0-5 is reserved place.
6. unique key generation method as described in claim 1, which is characterized in that according to real time in corresponding generation year, week, week
Several and second, comprising:
The second is generated since 00000 within daily first second, number of seconds is refreshed according to the variation of timing node automatically, it is per second to add 1 automatically, directly
It is 86400 to number of seconds, restarts to count the second;
If number of seconds adds 1 when the day before yesterday is identical as the next second date of arrival;
If resetting number of seconds when the day before yesterday and the next second date of arrival be not identical, the second is generated since 00000.
7. a kind of unique key generating means characterized by comprising
Module is obtained, for obtaining data to be generated;
First generation module is encoded for the corresponding Service Instance that generates of Service Instance sequence according to the data to be generated;
Second generation module, for according to real time in corresponding generation year, week, all several and seconds;
Third generation module, for corresponding to formation sequence number, extension bits and version according to preset rules;
Synthesis module, for above-mentioned generation field to be synthesized unique key according to unique key basic data structure, and will be described unique
Key is labeled in the data to be generated;Wherein, the generation field includes Service Instance coding, year, week, all several and second, sequence
Row number, extension bits and version.
8. unique key generating means as claimed in claim 7, which is characterized in that the preset rules, comprising:
The sequence number is generated according to preset order, wherein preset order includes in such a way that high-performance is locked in each service
Interior cumulative serial number data;
If it is different from the last sequence number generation time that current sequence number generates the time, with preset time period for a circulation,
The sequence number is generated since 0000, until formation sequence number 9999;
If the use of Present cycle time finishes, next circulation is waited, continues to generate the sequence number.
9. a kind of terminal device, including memory, processor and storage are in the memory and can be on the processor
The computer program of operation, which is characterized in that the processor realizes such as claim 1 to 6 when executing the computer program
The step of any one the method.
10. a kind of computer readable storage medium, the computer-readable recording medium storage has computer program, and feature exists
In when the computer program is executed by processor the step of any one of such as claim 1 to 6 of realization the method.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910146713.1A CN109933574B (en) | 2019-02-27 | 2019-02-27 | Unique key generation method and device and terminal equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910146713.1A CN109933574B (en) | 2019-02-27 | 2019-02-27 | Unique key generation method and device and terminal equipment |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109933574A true CN109933574A (en) | 2019-06-25 |
CN109933574B CN109933574B (en) | 2021-03-19 |
Family
ID=66985989
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910146713.1A Active CN109933574B (en) | 2019-02-27 | 2019-02-27 | Unique key generation method and device and terminal equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109933574B (en) |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110362573A (en) * | 2019-06-27 | 2019-10-22 | 北京大米科技有限公司 | Recommend generation method, device, electronic equipment and the storage medium of code |
CN111124635A (en) * | 2019-12-06 | 2020-05-08 | 北京达佳互联信息技术有限公司 | Task processing method and device, electronic equipment and storage medium |
CN111130784A (en) * | 2019-12-25 | 2020-05-08 | 成都海光集成电路设计有限公司 | Key generation method and device, CPU chip and server |
CN112445800A (en) * | 2020-11-20 | 2021-03-05 | 北京思特奇信息技术股份有限公司 | Method and system for generating data serial number and electronic equipment |
CN113641656A (en) * | 2021-08-19 | 2021-11-12 | 平安普惠企业管理有限公司 | Questionnaire answer management method, device, computer equipment and storage medium |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101039464A (en) * | 2007-05-16 | 2007-09-19 | 中兴通讯股份有限公司 | Method for making MBMS service support optional extended explanation and conversation method |
KR20090076587A (en) * | 2008-01-09 | 2009-07-13 | 삼성전자주식회사 | Method and apparatus transmitting/receiving packet data in mobile communication system |
CN106156050A (en) * | 2015-03-27 | 2016-11-23 | 阿里巴巴集团控股有限公司 | A kind of data processing method and device |
CN107205131A (en) * | 2016-03-18 | 2017-09-26 | 中兴通讯股份有限公司 | A kind of methods, devices and systems for realizing video calling |
CN108509433A (en) * | 2017-02-23 | 2018-09-07 | 北京京东金融科技控股有限公司 | The method, apparatus and electronic equipment of formation sequence number based on distributed system |
CN109063088A (en) * | 2018-07-26 | 2018-12-21 | 阿里巴巴集团控股有限公司 | The generation method and device of sequence number |
CN109074377A (en) * | 2016-03-29 | 2018-12-21 | 亚马逊科技公司 | Managed function for real-time processing data stream executes |
-
2019
- 2019-02-27 CN CN201910146713.1A patent/CN109933574B/en active Active
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101039464A (en) * | 2007-05-16 | 2007-09-19 | 中兴通讯股份有限公司 | Method for making MBMS service support optional extended explanation and conversation method |
KR20090076587A (en) * | 2008-01-09 | 2009-07-13 | 삼성전자주식회사 | Method and apparatus transmitting/receiving packet data in mobile communication system |
CN106156050A (en) * | 2015-03-27 | 2016-11-23 | 阿里巴巴集团控股有限公司 | A kind of data processing method and device |
CN107205131A (en) * | 2016-03-18 | 2017-09-26 | 中兴通讯股份有限公司 | A kind of methods, devices and systems for realizing video calling |
CN109074377A (en) * | 2016-03-29 | 2018-12-21 | 亚马逊科技公司 | Managed function for real-time processing data stream executes |
CN108509433A (en) * | 2017-02-23 | 2018-09-07 | 北京京东金融科技控股有限公司 | The method, apparatus and electronic equipment of formation sequence number based on distributed system |
CN109063088A (en) * | 2018-07-26 | 2018-12-21 | 阿里巴巴集团控股有限公司 | The generation method and device of sequence number |
Non-Patent Citations (1)
Title |
---|
吴耀芳: "基于应用代理的运维堡垒机研究与设计", 《中国优秀硕士学位论文全文数据库 信息科技辑》 * |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110362573A (en) * | 2019-06-27 | 2019-10-22 | 北京大米科技有限公司 | Recommend generation method, device, electronic equipment and the storage medium of code |
CN111124635A (en) * | 2019-12-06 | 2020-05-08 | 北京达佳互联信息技术有限公司 | Task processing method and device, electronic equipment and storage medium |
CN111130784A (en) * | 2019-12-25 | 2020-05-08 | 成都海光集成电路设计有限公司 | Key generation method and device, CPU chip and server |
CN111130784B (en) * | 2019-12-25 | 2023-08-08 | 成都海光集成电路设计有限公司 | Key generation method and device, CPU chip and server |
CN112445800A (en) * | 2020-11-20 | 2021-03-05 | 北京思特奇信息技术股份有限公司 | Method and system for generating data serial number and electronic equipment |
CN113641656A (en) * | 2021-08-19 | 2021-11-12 | 平安普惠企业管理有限公司 | Questionnaire answer management method, device, computer equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN109933574B (en) | 2021-03-19 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109933574A (en) | A kind of unique key generation method, device and terminal device | |
CN107278290A (en) | Building block system programs the method and device for being converted into program code | |
CN109558234A (en) | A kind of timed task dispatching method and device | |
CN108667867A (en) | Date storage method and device | |
CN108334408B (en) | Code execution method and device, terminal equipment and computer readable storage medium | |
CN111932257B (en) | Block chain parallelization processing method and device | |
CN109582452A (en) | A kind of container dispatching method, dispatching device and electronic equipment | |
CN104754008A (en) | Network storage node, network storage system and device and method for network storage node | |
Rajbhandari et al. | A communication-optimal framework for contracting distributed tensors | |
CN109840262A (en) | Data statistical approach and relevant apparatus | |
CN109492048A (en) | A kind of extracting method, system and the terminal device of power consumer electrical characteristics | |
CN108228754A (en) | flow generation method and terminal device | |
CN109885614A (en) | A kind of method and apparatus that data are synchronous | |
CN109241357A (en) | Chain structure model and its construction method, system and terminal device | |
CN110163349A (en) | A kind of calculation method and device of network model | |
CN115525724A (en) | Modeling method and system applied to data warehouse and electronic equipment | |
CN108446989A (en) | Service charge determines method and terminal device | |
EP3516515A1 (en) | Scheduling of tasks in a multiprocessor device | |
CN109542398A (en) | A kind of operation system generation method, device and computer readable storage medium | |
CN102521681A (en) | Remote sensing data quality monitoring system with extensible function and performance | |
CN111522840A (en) | Label configuration method, device, equipment and computer readable storage medium | |
CN109242321A (en) | Custom power load on-line analysis and terminal device | |
CN109063926A (en) | Plan generated energy determines method, system and terminal device in period | |
CN109213589A (en) | A kind of method and device of Message Processing | |
CN108762667A (en) | The method that the multi node server of disk can be dynamically distributed and dynamically distribute disk |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
TR01 | Transfer of patent right | ||
TR01 | Transfer of patent right |
Effective date of registration: 20211019 Address after: 337000 Building 5 and 7, artificial intelligence Industrial Park, Anyuan Industrial Park, Anyuan District, Pingxiang City, Jiangxi Province Patentee after: Jiangxi mammoth Energy Co.,Ltd. Address before: No. 31, Fengxiang Road, Wujin national high tech Industrial Development Zone, Changzhou City, Jiangsu Province 213100 Patentee before: CHANGZHOU MENGMA ELECTRIC TECHNOLOGY Co.,Ltd. |