sonyflake icon indicating copy to clipboard operation
sonyflake copied to clipboard

Add config to use all 64 bits

Open theory opened this issue 2 years ago • 0 comments

Add Use64Bits to Settings. When true, the bit length used for time will be 40 instead of 39. This allows for the generation of unique IDs for over 348 years from the start date.

Done by adding the bitLenTime field to the Sonyflake struct and using its value (39 or 40) to detect time overflows, rather than the constant BitLenTime. The new constant BitLenTimeUint is set to 40.

Update docs and note that values converted to int64 after 174 years will be negative.

theory avatar Oct 22 '23 20:10 theory