Summary of the invention
The embodiment of the invention provides a kind of ID generation methods, apparatus and system, can solve and provide ID in the related technology
The higher problem of application limitation.The technical solution is as follows:
In a first aspect, providing a kind of ID generation method, it to be used for server-side, which comprises
Receive the ID acquisition instruction that application end is initiated;
Target process mark and server-side mark are obtained, the target process, which is identified as in the server-side, executes the ID
The mark of the target process of acquisition instruction;
It is identified based on specified time stamp, target process mark, the server-side and from increasing sequence, generates Target id,
The specified time stamp is positively correlated with current time stamp, and the bit of the specified time stamp is higher than target process mark
The bit of bit and server-side mark, the bit from increasing sequence are lower than the bit of target process mark
The bit of position and server-side mark;
The Target id is sent to the application end.
Optionally, the acquisition target process mark, comprising:
The corresponding target process variable of the target process is obtained, process corresponding to different processes becomes in the server-side
Amount is different;
Based on process identification (PID) configuration file, the target process mark is obtained, the process identification (PID) configuration file is for depositing
The mapping relations of storage process variable and process identification (PID).
Optionally, described to be based on process identification (PID) configuration file, obtain the target process mark, comprising:
It detects and whether is stored with the target process variable and the target process mark in the process identification (PID) configuration file
The mapping relations of knowledge;
It is reflected when being stored with the target process variable in the process identification (PID) configuration file with what the target process identified
When penetrating relationship, the target process mark is obtained from the process identification (PID) configuration file.
Optionally, the target process variable and institute whether are stored in the detection process identification (PID) configuration file
After the mapping relations for stating target process mark, the method also includes:
There are the target process variable and the target process to identify when not stored in the process identification (PID) configuration file
When mapping relations, traverse the process identification (PID) configuration file, with obtain numerical value in the process identification (PID) configuration file it is maximum into
Journey mark;
1 obtained numerical value is added to be determined as the target process mark the maximum process identification (PID) of the numerical value;
The mapping of the target process variable and target process mark is stored in the process identification (PID) configuration file
Relationship obtains updated process identification (PID) configuration file.
Optionally, the acquisition server-side mark, comprising:
It detects in the system configuration file of the server-side and is identified with the presence or absence of the server-side, the server-side mark
Value range is 0 to N-1, and N is the maximum quantity for the server-side that system where the server-side is supported, N is positive integer;
When identifying in the system configuration file of the server-side there are the server-side, the server-side mark is obtained.
Optionally, it is identified with the presence or absence of the server-side in the system configuration file of the detection server-side
Afterwards, the method also includes:
When server-side mark is not present in the system configuration file of the server-side, from the O&M of the server-side
Server-side ID is obtained in configuration file;
By the server-side ID to N modulus, the server-side mark is obtained.
Optionally, the Target id by a high position to low level successively include marker bit, the specified time stamp, the target into
Journey identifies, the server-side identifies and described from increasing sequence;
Alternatively, the Target id successively includes marker bit, specified time stamp, the server-side mark by a high position to low level
Know, the target process identifies and described from increasing sequence.
Optionally, the bit wide of the Target id is 64;
The bit wide of the marker bit is 1, and the bit wide range of the specified time stamp is 35-45, the target process
The bit wide range of mark is 1-10, and the bit wide range of the server-side mark is 5-10, the bit wide model from increasing sequence
Enclose is 6-20.
Second aspect provides a kind of ID generating means, is used for server-side, and described device includes:
Receiving module, for receiving the ID acquisition instruction of application end initiation;
Module is obtained, for obtaining target process mark and server-side mark, the target process is identified as the service
The mark of the target process of the ID acquisition instruction is executed in end;
Generation module, for based on specified time stamp, target process mark, server-side mark and from increasing
Column generate Target id, and the specified time stamp is positively correlated with current time stamp, and the bit of the specified time stamp is higher than described
The bit of target process mark and the bit of server-side mark, the bit from increasing sequence are lower than the target
The bit of the bit of process identification (PID) and server-side mark;
Sending module, for sending the Target id to the application end.
Optionally, the acquisition module, is used for:
The corresponding target process variable of the target process is obtained, process corresponding to different processes becomes in the server-side
Amount is different;
Based on process identification (PID) configuration file, the target process mark is obtained, the process identification (PID) configuration file is for depositing
The mapping relations of storage process variable and process identification (PID).
Optionally, the acquisition module, is also used to:
It detects and whether is stored with the target process variable and the target process mark in the process identification (PID) configuration file
The mapping relations of knowledge;
It is reflected when being stored with the target process variable in the process identification (PID) configuration file with what the target process identified
When penetrating relationship, the target process mark is obtained from the process identification (PID) configuration file.
Optionally, the acquisition module, is also used to:
There are the target process variable and the target process to identify when not stored in the process identification (PID) configuration file
When mapping relations, traverse the process identification (PID) configuration file, with obtain numerical value in the process identification (PID) configuration file it is maximum into
Journey mark;
1 obtained numerical value is added to be determined as the target process mark the maximum process identification (PID) of the numerical value;
The mapping of the target process variable and target process mark is stored in the process identification (PID) configuration file
Relationship obtains updated process identification (PID) configuration file.
Optionally, the acquisition module, is used for:
It detects in the system configuration file of the server-side and is identified with the presence or absence of the server-side, the server-side mark
Value range is 0 to N-1, and N is the maximum quantity for the server-side that system where the server-side is supported, N is positive integer;
When identifying in the system configuration file of the server-side there are the server-side, the server-side mark is obtained.
Optionally, the acquisition module, is also used to:
When server-side mark is not present in the system configuration file of the server-side, from the O&M of the server-side
Server-side ID is obtained in configuration file;
By the server-side ID to N modulus, the server-side mark is obtained.
Optionally, the Target id by a high position to low level successively include marker bit, the specified time stamp, the target into
Journey identifies, the server-side identifies and described from increasing sequence;
Alternatively, the Target id successively includes marker bit, specified time stamp, the server-side mark by a high position to low level
Know, the target process identifies and described from increasing sequence.
Optionally, the bit wide of the Target id is 64;
The bit wide of the marker bit is 1, and the bit wide range of the specified time stamp is 35-45, the target process
The bit wide range of mark is 1-10, and the bit wide range of the server-side mark is 5-10, the bit wide model from increasing sequence
Enclose is 6-20.
The third aspect provides a kind of ID generation system, the system comprises: at least one server-side is answered at least one
With end, the server-side includes the ID generating means as described in second aspect is any.
Fourth aspect provides a kind of ID generating means, comprising: memory and processor;
The memory, for storing computer program;
The processor is realized for executing the computer program stored on the memory as first aspect is any
The ID generation method.
5th aspect, provides a kind of computer readable storage medium, the computer-readable recording medium storage has generation
Code instruction, the code command are executed by processor, realize the ID generation method as described in first aspect is any.
Technical solution bring beneficial effect provided in an embodiment of the present invention includes:
Specified time stamp, target process mark, server-side mark and from increasing column-generation Target id are based on by server-side.
Due to the server-side of different server-sides identify it is different, and in same server-side different processes process identification (PID) it is different, therefore can be with
The Target id for guaranteeing that the target process in server-side at a time generates is globally unique.On the one hand, Target id can be adopted
Form storage decimally, readable high, the search efficiency based on the Target id is high;On the other hand, due to specified time
Stamp is positively correlated with current time stamp, and the bit of specified time stamp is higher than the bit and server-side mark of target process mark
Bit, from the bit of increasing sequence lower than the bit of target process mark and the bit of server-side mark, Ke Yibao
The ID trend that card generates is incremented by.Therefore compared with the relevant technologies, the application limitation of Target id is reduced, Target id is expanded
Application range.
Specific embodiment
To make the object, technical solutions and advantages of the present invention clearer, below in conjunction with attached drawing to embodiment party of the present invention
Formula is described in further detail.
Fig. 1 is the structural schematic diagram that a kind of ID provided in an embodiment of the present invention generates system, as shown in Figure 1, the ID is generated
System 10 includes at least one server-side 101 and at least one application end 102.It is exemplary, it generates system 10 referring to Fig. 1, ID and wraps
Include two server-sides 101 and three application ends 102.Each server-side 101 can pass through wired network at least one application end 102
Network or wireless network establish communication connection.
Optionally, server-side 101 is alternatively referred to as machine node.Server-side 101 can be server, such as server-side can be with
It is the background server of some gaming platform;Or server-side 101 can be a cloud computing service center.Application end 102 can
To be the terminals such as smart phone, tablet computer and wearable device.It is not limited in the embodiment of the present invention.Server-side 101 is used
In providing globally unique ID to the application end 102 of connection.
In embodiments of the present invention, by being packaged to snowflake (snowflake) algorithm, server-side 101 is made to be based on envelope
Snowflake algorithm after dress generates globally unique ID, the ID include marker bit, specified time stamp, process identification (PID), server-side identify and
From increasing sequence, specified time stamp is positively correlated with current time stamp.Wherein, the bit of marker bit is the highest order in ID, is specified
The bit of timestamp is higher than the bit of target process mark and the bit of server-side mark, low from the bit of increasing sequence
In the bit of target process mark and the bit of server-side mark, that is to say, the ID that server-side generates is by a high position to low level
It successively include marker bit, specified time stamp, target process mark, server-side mark and from increasing sequence;Alternatively, what server-side generated
ID successively includes marker bit, specified time stamp, server-side mark, target process mark and from increasing sequence by a high position to low level.
Optionally, marker bit is alternatively referred to as sign bit, and when marker bit is 1, expression ID is positive number;When marker bit be 0, indicate
ID is negative.
It should be noted that the server-side of different server-sides identifies difference in ID generation system, that is to say for entire
For ID generation system, server-side mark is globally unique;In each server-side, the process identification (PID) of different processes is different,
It that is to say for single server-side, process identification (PID) is globally unique.Wherein, target process mark and server-side mark are equal
For number.In addition, being number due to specified time stamp and from increasing sequence, ID provided in an embodiment of the present invention generates system
The ID of generation can be stored using metric form.
Optionally, ID provided in an embodiment of the present invention, which generates system, can be integrated system, be also possible to distributed system
System, does not limit this.
Fig. 2 is a kind of flow chart of ID generation method provided in an embodiment of the present invention, generates system for ID as shown in Figure 1
Any server-side 101 in system 10, as shown in Fig. 2, this method comprises:
Step 201 receives the ID acquisition instruction that application end is initiated.
Step 202 obtains target process mark and server-side mark.
Wherein, target process is identified as the mark that the target process of ID acquisition instruction is executed in server-side.
Step 203 is identified based on specified time stamp, target process mark, server-side and from increasing sequence, generates Target id.
Wherein, specified time stamp is positively correlated with current time stamp.The bit of specified time stamp is identified higher than target process
Bit and server-side mark bit, bit and server-side from the bit of increasing sequence lower than target process mark
The bit of mark.
Optionally, Target id is generated by target process.
Step 204 sends Target id to application end.
In conclusion ID generation method provided in an embodiment of the present invention, server-side is based on specified time stamp, target process mark
Know, server-side mark and from increasing column-generation Target id.Since the server-side of different server-sides identifies difference, and same server-side
The process identification (PID) of middle difference process is different, therefore can guarantee the Target id that the target process in server-side at a time generates
It is globally unique.On the one hand, Target id can be stored using metric form, readable high, based on the Target id
Search efficiency is high;On the other hand, it is positively correlated due to specified time stamp with current time stamp, and the bit of specified time stamp is higher than
The bit of target process mark and the bit of server-side mark, the ratio of target process mark is lower than from the bit of increasing sequence
The bit of special position and server-side mark, it is ensured that the ID trend of generation is incremented by.Therefore compared with the relevant technologies, mesh is reduced
The application limitation for marking ID, expands the application range of Target id.
Fig. 3 is the flow chart of another kind ID generation method provided in an embodiment of the present invention, is generated for ID as shown in Figure 1
In system 10, as shown in figure 3, this method comprises:
Step 301, application end send ID acquisition instruction to server-side.
Optionally, the ID acquisition instruction that application end is sent is used to indicate server-side and generates corresponding ID.
Exemplary, application end is to be equipped with the terminal of game client, and server-side is after the corresponding game of game client
Platform server.For example, ID acquisition instruction can be generated in game client when user creates virtual room on game client
And the ID acquisition instruction is sent to game background server, which is used to indicate game background server and generates the void
The quasi- corresponding ID in room (i.e. room number);In another example when user applies for login account on game client, game client
ID acquisition instruction can be generated and send the ID acquisition instruction to game background server, which is used to indicate game
Background server generates the corresponding ID of the login account.
Optionally, ID acquisition instruction may be used to indicate that server-side generate serial number, the serial number for server-side to
Corresponding application end granting reward (such as ideal money, integral, cash and Fu Ka) etc., the embodiment of the present invention is to ID generation method
Application scenarios without limitation.
Step 302, server-side obtain target process mark.
Wherein, target process is identified as the mark that the target process of ID acquisition instruction is executed in server-side.
Optionally, step 302 the realization process includes:
S21, the corresponding target process variable of target process is obtained, process variable corresponding to different processes is not in server-side
Together.
It should be noted that the process variable of each process is that process is privately owned, therefore different processes are corresponding in server-side
Process variable is different, which can unique identification process.
S22, it is based on process identification (PID) configuration file, obtains target process mark, the process identification (PID) configuration file is for storing
The mapping relations of process variable and process identification (PID).
Optionally, as shown in figure 4, it is above-mentioned S22's the realization process includes:
Target process variable and target process mark whether are stored in step 221, detection procedure mark configuration file
Mapping relations;When being stored with the mapping relations of target process variable and target process mark in process identification (PID) configuration file, hold
Row step 222;There are target process variable and the mapping of target process mark to close when not stored in process identification (PID) configuration file
When being, step 223 is executed.
Optionally, the corresponding process variable of all processes in server-side has been can store in process identification (PID) configuration file.
Step 222 obtains target process mark from process identification (PID) configuration file.
Step 223, traversal process identification (PID) configuration file, to obtain the maximum process mark of numerical value in process identification (PID) configuration file
Know.
Step 224 adds the maximum process identification (PID) of numerical value 1 obtained numerical value to be determined as target process mark.
Exemplary, when the bit wide of process identification (PID) is 3bit, the value range of the process identification (PID) is 0 to 7, if process identification (PID)
The maximum process identification (PID) of numerical value is 4 in configuration file, it is determined that target process is identified as 5.
Optionally, with reference to step 223 and step 224, server-side increasing can store respectively in process identification (PID) configuration file
The corresponding process identification (PID) of a process;Alternatively, server-side can also store each process pair by descending in process identification (PID) configuration file
The process identification (PID) answered, then step 223 and step 224 could alternatively be: traversal process identification (PID) configuration file, to obtain process identification (PID)
The smallest process identification (PID) of numerical value in configuration file;The numerical value for subtracting 1 for the maximum process identification (PID) of numerical value and obtaining is determined as target process
Mark.Server-side can also store the corresponding process identification (PID) of each process using other modes in process identification (PID) configuration file,
It only needs to guarantee that the corresponding process identification (PID) of each process is unique and interior in value range, the embodiment of the present invention does not limit this
It is fixed.
Step 225, the mapping relations that target process variable and target process mark are stored in process identification (PID) configuration file,
Obtain updated process identification (PID) configuration file.
It optionally, can be based on updated process identification (PID) configuration text when server-side receives ID acquisition instruction again
Part obtains the corresponding process identification (PID) of process for executing the ID acquisition instruction, which can refer to above-mentioned steps 221 to step 225,
The embodiment of the present invention is to this will not be repeated here.
In embodiments of the present invention, server-side combines the application system of itself, and realization without immersion obtains process identification (PID),
It can be applied to a variety of distributed systems, versatility is high.
Step 303, server-side obtain server-side mark.
Optionally, step 303 the realization process includes:
S31, detection service end system configuration file in the presence or absence of server-side identify, server-side mark value range
It is 0 to N-1, N is the maximum quantity for the server-side that system where server-side is supported, N is positive integer.
It should be noted that the server-side in system configuration file is identified as number.When the bit wide of server-side mark is p
When bit, the maximum quantity N for the server-side that system where the server-side is supported is 2pWhen, then the clothes that are stored in system configuration file
The value range for end mark of being engaged in is 0 to 2p-1。
S32, when in the system configuration file of server-side presence service end identify when, obtain server-side mark.
S33, when in the system configuration file of server-side be not present server-side mark when, from the O&M configuration file of server-side
Middle acquisition server-side ID.
Wherein, server-side ID is alternatively referred to as machine ID.The server-side ID of different server-sides is different, i.e., server-side ID can be unique
Identify server-side.
S34, by server-side ID to N modulus, obtain server-side mark.
Since the numerical value of server-side ID is likely larger than or is equal to N, the value by server-side ID to N modulus, after making modulus
In value range in server-side mark.
In embodiments of the present invention, server-side combines the application system of itself, and realization without immersion obtains server-side mark
Know, can be applied to a variety of distributed systems, versatility is high.
Step 304, server-side are based on specified time stamp, target process mark, server-side and identify and from increasing sequence, generate mesh
Mark ID.
Wherein, specified time stamp is positively correlated with current time stamp.Specified time stamp can be equal to current time stamp and history
The difference of timestamp.Optionally, historical time stamp can be timestamp when server-side brings into operation, and be also possible to when current
Some set time stamp before quarter, it is not limited in the embodiment of the present invention.
It should be noted that the bit of specified time stamp was identified higher than the bit and server-side of target process mark
Bit is lower than the bit of target process mark and the bit of server-side mark from the bit of increasing sequence.In addition, target
ID further includes marker bit, and marker bit is the highest order in Target id.Optionally, Target id successively includes label by a high position to low level
Position, specified time stamp, target process mark, server-side mark and from increasing sequence;Alternatively, Target id is successively wrapped by a high position to low level
Include marker bit, specified time stamp, server-side mark, target process mark and from increasing sequence.
Optionally, specified time stamp and from increasing sequence be Millisecond.
Optionally, the bit wide of Target id is 64bit, and the bit wide of marker bit is 1bit, the bit wide of specified time stamp, target into
Journey mark bit wide, server-side mark bit wide and from the sum of bit wide of increasing sequence be 63bit.Optionally, specified time stabs
Bit wide range be 35-45, target process mark bit wide range be 1-10, server-side identify bit wide range be 5-10
Position is 6-20 from the bit wide range of increasing sequence.The Target id is long type.In practical application scene, specified time stamp
Bit wide, the bit wide of target process mark, the bit wide of server-side mark and the bit wide from increasing sequence can be set according to actual needs
Fixed and adjustment, it is not limited in the embodiment of the present invention.
In embodiments of the present invention, when specified time stamp is Millisecond, the specified time stamp that bit wide is m bit is available
Year T=(1L < < m)/(1000L*60*60*24*365), wherein " < < " indicates to press bitwise shift left;The position of target process mark
Width is n bit, then the server-side is supported while running at most 2nA process;The bit wide of server-side mark is p bit, the then service
ID where end, which generates system, can at most support 2pA server-side;It is q from the bit wide of increasing sequence when being classified as Millisecond from increasing
Bit, then each process supports that every millisecond at most generates 2qA ID.Wherein, m, n, p and q are positive integer.
Optionally, it includes: that store bit wide be q bit from increasing sequence that server-side, which generates the software implementing course of Target id,;
The server-side that q storage bit wides are p bit is moved to left to identify;The target process that the position (p+q) storage bit wide is n bit is moved to left to identify,
Move to left the specified time stamp that the position (p+q+n) storage bit wide is m bit.Wherein, Target id can be generated by target process.
It should be noted that the bit wide for the Target id that the embodiment of the present invention generates is 64bit, and the bit wide of UUID is
128bit, therefore compared with the UUID that the relevant technologies provide, the occupied memory space of Target id provided in an embodiment of the present invention
It is smaller, storage resource can be saved.
Step 305, server-side send Target id to application end.
Optionally, the identification information of the application end is carried in the ID acquisition instruction that application end is sent, server-side is based on should
The identification information of application end sends the Target id generated to the application end, for application end use.
It should be noted that the step sequencing of ID generation method provided in an embodiment of the present invention can be adjusted suitably
It is whole, such as step 303 can execute before step 302 or step 302 can be performed simultaneously with step 303, step can also
According to circumstances accordingly to be increased and decreased, anyone skilled in the art in the technical scope disclosed by the present invention,
The method that variation can be readily occurred in, should be covered by the protection scope of the present invention, therefore repeat no more.
In conclusion ID generation method provided in an embodiment of the present invention, server-side is based on specified time stamp, target process mark
Know, server-side mark and from increasing column-generation Target id.Since the server-side of different server-sides identifies difference, and same server-side
The process identification (PID) of middle difference process is different, therefore can guarantee the Target id that the target process in server-side at a time generates
It is globally unique.On the one hand, Target id can be stored using metric form, readable high, based on the Target id
Search efficiency is high;On the other hand, it is positively correlated due to specified time stamp with current time stamp, and the bit of specified time stamp is higher than
The bit of target process mark and the bit of server-side mark, the ratio of target process mark is lower than from the bit of increasing sequence
The bit of special position and server-side mark, it is ensured that the ID trend of generation is incremented by.In addition, ID provided in an embodiment of the present invention is raw
At method, different databases can be applied to, therefore compared with the relevant technologies, reduce the application limitation of Target id, expand
The big application range of Target id.
Fig. 5 is a kind of structural schematic diagram of ID generating means provided in an embodiment of the present invention, raw for ID as shown in Figure 1
At any server-side 101 in system 10, as shown in figure 5, the device 40 includes:
Receiving module 401, for receiving the ID acquisition instruction of application end initiation.
Module 402 is obtained, for obtaining target process mark and server-side mark, target process is identified as in server-side and holds
The mark of the target process of row ID acquisition instruction.
Generation module 403, for being identified based on specified time stamp, target process mark, server-side and from increasing sequence, being generated
Target id, specified time stamp are positively correlated with current time stamp, and the bit of specified time stamp is higher than the bit of target process mark
The bit of position and server-side mark, bit and server-side mark from the bit of increasing sequence lower than target process mark
Bit.
Sending module 404, for sending Target id to application end.
In conclusion ID generating means provided in an embodiment of the present invention, server-side is based on specified time by generation module
Stamp, target process mark, server-side mark and from increasing column-generation Target id.Since the server-side of different server-sides identifies not
Together, the process identification (PID) of different processes is different and in same server-side, therefore the target process in server-side can be guaranteed a certain
The Target id that moment generates is globally unique.On the one hand, Target id can be stored using metric form, readable
Height, the search efficiency based on the Target id are high;On the other hand, it is positively correlated due to specified time stamp with current time stamp, and specified
The bit of timestamp is higher than the bit of target process mark and the bit of server-side mark, low from the bit of increasing sequence
In the bit of target process mark and the bit of server-side mark, it is ensured that the ID trend of generation is incremented by.In addition, this hair
The ID generation method that bright embodiment provides, can be applied to different databases, therefore compared with the relevant technologies, reduce target
The application limitation of ID expands the application range of Target id.
Optionally, module is obtained, is used for:
The corresponding target process variable of target process is obtained, process variable corresponding to different processes is different in server-side;
Based on process identification (PID) configuration file, target process mark is obtained, process identification (PID) configuration file is used for storage process variable and process
The mapping relations of mark.
Optionally, module is obtained, is also used to:
Whether the mapping relations of target process variable and target process mark are stored in detection procedure mark configuration file;
When being stored with the mapping relations of target process variable and target process mark in process identification (PID) configuration file, match from process identification (PID)
It sets and obtains target process mark in file.
Optionally, module is obtained, is also used to:
When the not stored mapping relations for having target process variable and target process mark in process identification (PID) configuration file, time
Process identification (PID) configuration file is gone through, to obtain the maximum process identification (PID) of numerical value in process identification (PID) configuration file;By numerical value it is maximum into
Journey mark plus 1 obtained numerical value are determined as target process mark;In process identification (PID) configuration file store target process variable with
The mapping relations of target process mark, obtain updated process identification (PID) configuration file.
Optionally, module is obtained, is used for:
It is identified in the system configuration file at detection service end with the presence or absence of server-side, the value range of server-side mark is 0
To N-1, N is the maximum quantity for the server-side that system where server-side is supported, N is positive integer;When the system configuration text of server-side
When presence service end identifies in part, server-side mark is obtained.
Optionally, module is obtained, is also used to:
When server-side mark is not present in the system configuration file of server-side, obtained from the O&M configuration file of server-side
Take server-side ID;By server-side ID to N modulus, server-side mark is obtained.
Optionally, Target id successively includes marker bit, specified time stamp, target process mark, service by a high position to low level
End mark and from increasing sequence;Alternatively, Target id by a high position to low level successively include marker bit, specified time stamp, server-side mark,
Target process mark and from increasing sequence.
Optionally the bit wide of Target id is 64;The bit wide of marker bit is 1, and the bit wide range of specified time stamp is 35-
45, the bit wide range of target process mark is 1-10, and the bit wide range of server-side mark is 5-10, from the position of increasing sequence
Wide scope is 6-20.
In conclusion ID generating means provided in an embodiment of the present invention, server-side is based on specified time by generation module
Stamp, target process mark, server-side mark and from increasing column-generation Target id.Since the server-side of different server-sides identifies not
Together, the process identification (PID) of different processes is different and in same server-side, therefore the target process in server-side can be guaranteed a certain
The Target id that moment generates is globally unique.On the one hand, Target id can be stored using metric form, readable
Height, the search efficiency based on the Target id are high;On the other hand, it is positively correlated due to specified time stamp with current time stamp, and specified
The bit of timestamp is higher than the bit of target process mark and the bit of server-side mark, low from the bit of increasing sequence
In the bit of target process mark and the bit of server-side mark, it is ensured that the ID trend of generation is incremented by.In addition, this hair
The ID generation method that bright embodiment provides, can be applied to different databases, therefore compared with the relevant technologies, reduce target
The application limitation of ID expands the application range of Target id.
About the device in above-described embodiment, wherein modules execute the concrete mode of operation in related this method
Embodiment in be described in detail, no detailed explanation will be given here.
The embodiment of the invention provides a kind of ID to generate system, as shown in Figure 1, the system includes: at least one server-side
101 and at least one application end 102, the server-side includes ID generating means as shown in Figure 5.
The embodiment of the invention provides a kind of ID generating means, comprising: memory and processor;
The memory, for storing computer program;
The processor is realized as shown in Figure 2 or Figure 3 for executing the computer program stored on the memory
ID generation method.
Fig. 6 is a kind of structural schematic diagram of server-side provided in an embodiment of the present invention, which can be server.Institute
Stating server 500 includes central processing unit (Central Processing Unit, CPU) 501 including random access memory
The system of device (random access memory, RAM) 502 and read-only memory (read only memory, ROM) 503 is deposited
Reservoir 504, and the system bus 505 of connection system storage 504 and central processing unit 501.The server 500 also wraps
The basic input/output (I/O system) 506 for helping that information is transmitted between each device in computer is included, and for depositing
Store up the mass-memory unit 507 of operating system 513, application program 514 and other program modules 515.
The basic input/output 506 includes display 508 for showing information and inputs letter for user
The input equipment 509 of such as mouse, keyboard etc of breath.Wherein the display 508 and input equipment 509 are all by being connected to
The input and output controller 510 of system bus 505 is connected to central processing unit 501.The basic input/output 506
Can also include input and output controller 510 with for receive and handle from keyboard, mouse or electronic touch pen etc. it is multiple its
The input of his equipment.Similarly, input and output controller 510 also provides output to display screen, printer or other kinds of defeated
Equipment out.
The mass-memory unit 507 is by being connected to the bulk memory controller (not shown) of system bus 505
It is connected to central processing unit 501.The mass-memory unit 507 and its associated computer-readable medium are server
500 provide non-volatile memories.That is, the mass-memory unit 507 may include such as hard disk or CD-ROM
The computer-readable medium (not shown) of driver etc.
Without loss of generality, the computer-readable medium may include computer storage media and communication media.Computer
Storage medium includes information such as computer readable instructions, data structure, program module or other data for storage
The volatile and non-volatile of any method or technique realization, removable and irremovable medium.Computer storage medium includes
RAM, ROM, EPROM, EEPROM, flash memory or other solid-state storages its technologies, CD-ROM, DVD or other optical storages, tape
Box, tape, disk storage or other magnetic storage devices.Certainly, skilled person will appreciate that the computer storage medium
It is not limited to above-mentioned several.Above-mentioned system storage 504 and mass-memory unit 507 may be collectively referred to as memory.
According to various embodiments of the present invention, the server 500 can also be arrived by network connections such as internets
Remote computer operation on network.Namely server 500 can be by the network interface that is connected on the system bus 505
Unit 511 is connected to network 512, in other words, Network Interface Unit 511 also can be used be connected to other kinds of network or
Remote computer system (not shown).
The memory further includes that one or more than one program, the one or more programs are stored in
In memory, central processing unit 501 realizes that Fig. 2 or ID shown in Fig. 3 is raw by executing one or more programs
At method.
The embodiment of the invention provides a kind of computer readable storage medium, the computer-readable recording medium storage has
Code command, the code command are executed by processor, realize ID generation method as shown in Figure 2 or Figure 3.
Those of ordinary skill in the art will appreciate that realizing that all or part of the steps of above-described embodiment can pass through hardware
It completes, relevant hardware can also be instructed to complete by program, the program can store in a kind of computer-readable
In storage medium, storage medium mentioned above can be read-only memory, disk or CD etc..
The foregoing is merely alternative embodiments of the invention, are not intended to limit the invention, it is all in spirit of the invention and
Within principle, any modification, equivalent replacement, improvement and so on be should all be included in the protection scope of the present invention.