Generating unique ids in Mnesia

Mark Scandariato mfs@REDACTED
Thu Aug 18 18:12:43 CEST 2005


erlang:now/0 returns  {Megaseconds, Seconds, Microseconds} since 00:00 GMT, January 1, 1970.

Seconds and Microseconds wrap at 999,999 so they won't exceed 20 bits.

You'll have to hang on to the sequence numbers for a very long time before you exceed 24 bits worth of Megaseconds (16 trillion seconds since 00:00 GMT, January 1, 1970).

Mark.

-----Original Message-----
From: Joel Reymont <joelr1@REDACTED>
Sent: Aug 18, 2005 11:35 AM
To: Erlang Users' List <erlang-questions@REDACTED>
Subject: Re: Generating unique ids in Mnesia

Is it fixed someplace that the components of now() are exactly 24, 20  
and 20 bits long?

On Aug 18, 2005, at 5:29 PM, Mark Scandariato wrote:

> If you don't mind gaps in the sequence numbers, then try:
>
> seq() ->
>     {M,S,U} = erlang:now(),
>     <<N:64>> = <<M:24, S:20, U:20>>,
>     N.






More information about the erlang-questions mailing list