You are not logged in.
AS title .
Windows 7 64bit. Delphi XE10.2 Professional.
Offline
Check SynCommon's TSynUniqueIdentifier.
They are 64-bit integer unique identifier, globally on a system (up to 32K nodes), without the need of any centralized server.
You have other features, like ID obfuscation into URI, or built-in storage of the ID timestamp creation.
Offline
Means I can generate ID (64bit) on client with 100% assurance that will not collide with another ID?
Offline
The algorithm used ensure that.
If each TSynUniqueIdentifierGenerator has a single ProcessID value (set e.g. in the settings file of the node), then you can be sure that there won't be any collision.
Another benefit is that it is time-based, so it will be globally increasing (which eases a lot indexation and balancing), and you can retrieve the creation timestamp from the ID (no need to have the time stored in another field).
Offline
could be work like this :
IdWorker worker1 = new IdWorker(1); //process(thread) 1
System.out.println(worker1.nextId());
IdWorker worker2 = new IdWorker(2); //process(thread) 2
System.out.println(worker2.nextId());
Windows 7 64bit. Delphi XE10.2 Professional.
Offline
Yes, of course.
But in the same process, the TSynUniqueIdentifierGenerator is thread-safe, so you can use it on all threads of the same process.
No need to create several TSynUniqueIdentifierGenerator with their own process ID in the same process.
Offline
The algorithm used ensure that.
If each TSynUniqueIdentifierGenerator has a single ProcessID value (set e.g. in the settings file of the node), then you can be sure that there won't be any collision.
Another benefit is that it is time-based, so it will be globally increasing (which eases a lot indexation and balancing), and you can retrieve the creation timestamp from the ID (no need to have the time stored in another field).
I thought that ProcessID = Windows ProcessID or something like this. I get it now, but needs that every node to be registered and get a unique ProcessID before can post to server. It not a big deal. Also it must keep track of many instances of the client to have different ProcessID.
But I think it's not safe enough.. I saw many times (for different reasons) that client time is set back manually for let's say 2 hours, so with a "little luck" the same time can occur again in the same ProcessID.
Offline
generate 100000000 ids cost => Gettickcount: 5320 ms.
can't not believe that fast .
--
it got 19 digits ,like 3231448769769799708 . a little too long;
Windows 7 64bit. Delphi XE10.2 Professional.
Offline
Do you mean it is fast, or slow?
I believe it is fast. And thread-safe.
19 digits is in fact a 63-bit number, so that we won't suffer for the value sign (older Delphi doesn't support properly unsigned 64-bit QWord).
Why is it "too long" for you? If it is for JavaScript process for instance (which only handles 53-bit for integers), you can just convert it into an hexadecimal string.
Offline
it is fast for sure .
"too long" , the reason is for cross language as you wroted.
hexadecimal is a string can not be saved as int in database.
Windows 7 64bit. Delphi XE10.2 Professional.
Offline