File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ public function nextId(): string {
3535 $ serverId = $ this ->getServerId () & 0x1FF ; // Keep 9 bits
3636 $ isCli = (int )$ this ->isCli (); // 1 bit
3737 $ sequenceId = $ this ->getSequenceId ($ seconds , $ milliseconds , $ serverId ); // 12 bits
38- if ($ sequenceId > 0xFFF ) {
38+ if ($ sequenceId > 0xFFF || $ sequenceId === false ) {
3939 // Throttle a bit, wait for next millisecond
4040 usleep (1000 );
4141 return $ this ->nextId ();
@@ -109,6 +109,12 @@ private function isCli(): bool {
109109 return PHP_SAPI === 'cli ' ;
110110 }
111111
112+ /**
113+ * Generates sequence ID from APCu (general case) or random if APCu disabled or CLI
114+ *
115+ * @return int|false Sequence ID or false if APCu not ready
116+ * @throws \Exception if there is an error with APCu
117+ */
112118 private function getSequenceId (int $ seconds , int $ milliseconds , int $ serverId ): int |false {
113119 $ key = 'seq: ' . $ seconds . ': ' . $ milliseconds ;
114120
You can’t perform that action at this time.
0 commit comments