You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -40,7 +40,7 @@ Snowflake is a network service for generating unique ID numbers at high scale wi
40
40
> You must know, The ID generated by the snowflake algorithm is not guaranteed to be unique.
41
41
> For example, when two different requests enter the same node of the same data center at the same time, and the sequence generated by the node is the same, the generated ID will be duplicated.
42
42
43
-
So if you want use the snowflake algorithm to generate unique ID, You must ensure: The sequence-number generated in the same millisecond of the same node is unique.
43
+
So if you want to use the snowflake algorithm to generate unique ID, You must ensure: The sequence-number generated in the same millisecond of the same node is unique.
44
44
Based on this, we created this package and integrated multiple sequence-number providers into it.
45
45
46
46
* RandomSequenceResolver (Random)
@@ -55,7 +55,7 @@ Each provider only needs to ensure that the serial number generated in the same
thrownew\Exception(sprintf('The current microtime - starttime is not allowed to exceed -1 ^ (-1 << %d), You can reset the start time to fix this', self::MAX_TIMESTAMP_LENGTH));
148
+
thrownewException(sprintf('The current microtime - starttime is not allowed to exceed -1 ^ (-1 << %d), You can reset the start time to fix this', self::MAX_TIMESTAMP_LENGTH));
143
149
}
144
150
145
-
$this->startTime = $startTime;
151
+
$this->startTime = $millisecond;
146
152
147
153
return$this;
148
154
}
@@ -154,7 +160,7 @@ public function setStartTimeStamp(int $startTime)
154
160
*/
155
161
publicfunctiongetStartTimeStamp()
156
162
{
157
-
if ($this->startTime > 0) {
163
+
if (! is_null($this->startTime)) {
158
164
return$this->startTime;
159
165
}
160
166
@@ -167,7 +173,7 @@ public function getStartTimeStamp()
167
173
/**
168
174
* Set Sequence Resolver.
169
175
*
170
-
* @param callable|SequenceResolver $sequence
176
+
* @param callable|SequenceResolver $sequence
171
177
*/
172
178
publicfunctionsetSequenceResolver($sequence)
173
179
{
@@ -179,7 +185,7 @@ public function setSequenceResolver($sequence)
0 commit comments