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 ;
@@ -236,7 +236,7 @@ public function save(Key $key)
236
236
237
237
try {
238
238
$ this ->upsert ($ key ,$ this ->initialTtl );
239
- }catch (WriteException $ e ) {
239
+ }catch (BulkWriteException $ e ) {
240
240
if ($ this ->isDuplicateKeyException ($ e )) {
241
241
throw new LockConflictedException ('Lock was acquired by someone else. ' ,0 ,$ e );
242
242
}
@@ -262,7 +262,7 @@ public function putOffExpiration(Key $key, float $ttl)
262
262
263
263
try {
264
264
$ this ->upsert ($ key ,$ ttl );
265
- }catch (WriteException $ e ) {
265
+ }catch (BulkWriteException $ e ) {
266
266
if ($ this ->isDuplicateKeyException ($ e )) {
267
267
throw new LockConflictedException ('Failed to put off the expiration of the lock. ' ,0 ,$ e );
268
268
}
@@ -348,7 +348,7 @@ private function upsert(Key $key, float $ttl): void
348
348
$ this ->getManager ()->executeBulkWrite ($ this ->namespace ,$ write );
349
349
}
350
350
351
- private function isDuplicateKeyException (WriteException $ e ):bool
351
+ private function isDuplicateKeyException (BulkWriteException $ e ):bool
352
352
{
353
353
$ code =$ e ->getCode ();
354
354
@@ -371,7 +371,7 @@ private function getManager(): Manager
371
371
*/
372
372
private function createMongoDateTime (float $ seconds ):UTCDateTime
373
373
{
374
- return new UTCDateTime ($ seconds *1000 );
374
+ return new UTCDateTime (( int ) ( $ seconds *1000 ) );
375
375
}
376
376
377
377
/**