@@ -141,9 +141,10 @@ public function get(): ?array
141
141
if ($ this ->autoSetup ) {
142
142
$ this ->setup ();
143
143
}
144
+ $ now = 1000 * microtime (true );
144
145
145
146
try {
146
- $ queuedMessageCount = $ this ->connection ->zcount ($ this ->queue , 0 , $ this -> getCurrentTimeInMilliseconds () );
147
+ $ queuedMessageCount = $ this ->connection ->zcount ($ this ->queue , 0 , $ now );
147
148
} catch (\RedisException $ e ) {
148
149
throw new TransportException ($ e ->getMessage (), 0 , $ e );
149
150
}
@@ -164,7 +165,7 @@ public function get(): ?array
164
165
$ this ->add (
165
166
$ queuedMessage ['body ' ],
166
167
$ queuedMessage ['headers ' ],
167
- $ time - $ this -> getCurrentTimeInMilliseconds ()
168
+ $ time - $ now
168
169
);
169
170
}
170
171
}
@@ -255,7 +256,7 @@ public function add(string $body, array $headers, int $delayInMs = 0): void
255
256
}
256
257
257
258
try {
258
- if ($ delayInMs > 0 ) { // the delay could be smaller 0 in a queued message
259
+ if ($ delayInMs > 0 ) { // the delay could be smaller than 0 in a queued message
259
260
$ message = json_encode ([
260
261
'body ' => $ body ,
261
262
'headers ' => $ headers ,
@@ -267,7 +268,7 @@ public function add(string $body, array $headers, int $delayInMs = 0): void
267
268
throw new TransportException (json_last_error_msg ());
268
269
}
269
270
270
- $ score = $ this -> getCurrentTimeInMilliseconds ( ) + $ delayInMs ;
271
+ $ score = 1000 * microtime ( true ) + $ delayInMs ;
271
272
$ added = $ this ->connection ->zadd ($ this ->queue , ['NX ' ], $ score , $ message );
272
273
} else {
273
274
$ message = json_encode ([
@@ -316,11 +317,6 @@ public function setup(): void
316
317
$ this ->autoSetup = false ;
317
318
}
318
319
319
- private function getCurrentTimeInMilliseconds (): int
320
- {
321
- return (int ) (microtime (true ) * 1000 );
322
- }
323
-
324
320
public function cleanup (): void
325
321
{
326
322
$ this ->connection ->del ($ this ->stream );
0 commit comments