17
17
use MongoDB \Database ;
18
18
use MongoDB \Driver \BulkWrite ;
19
19
use MongoDB \Driver \Command ;
20
- use MongoDB \Driver \Exception \WriteException ;
20
+ use MongoDB \Driver \Exception \BulkWriteException ;
21
21
use MongoDB \Driver \Manager ;
22
22
use MongoDB \Driver \Query ;
23
23
use MongoDB \Exception \DriverRuntimeException ;
@@ -225,7 +225,7 @@ public function save(Key $key): void
225
225
226
226
try {
227
227
$ this ->upsert ($ key , $ this ->initialTtl );
228
- } catch (WriteException $ e ) {
228
+ } catch (BulkWriteException $ e ) {
229
229
if ($ this ->isDuplicateKeyException ($ e )) {
230
230
throw new LockConflictedException ('Lock was acquired by someone else. ' , 0 , $ e );
231
231
}
@@ -249,7 +249,7 @@ public function putOffExpiration(Key $key, float $ttl): void
249
249
250
250
try {
251
251
$ this ->upsert ($ key , $ ttl );
252
- } catch (WriteException $ e ) {
252
+ } catch (BulkWriteException $ e ) {
253
253
if ($ this ->isDuplicateKeyException ($ e )) {
254
254
throw new LockConflictedException ('Failed to put off the expiration of the lock. ' , 0 , $ e );
255
255
}
@@ -332,7 +332,7 @@ private function upsert(Key $key, float $ttl): void
332
332
$ this ->getManager ()->executeBulkWrite ($ this ->namespace , $ write );
333
333
}
334
334
335
- private function isDuplicateKeyException (WriteException $ e ): bool
335
+ private function isDuplicateKeyException (BulkWriteException $ e ): bool
336
336
{
337
337
$ code = $ e ->getCode ();
338
338
@@ -355,7 +355,7 @@ private function getManager(): Manager
355
355
*/
356
356
private function createMongoDateTime (float $ seconds ): UTCDateTime
357
357
{
358
- return new UTCDateTime ($ seconds * 1000 );
358
+ return new UTCDateTime (( int ) ( $ seconds * 1000 ) );
359
359
}
360
360
361
361
/**
0 commit comments