Skip to content

Commit 3a0203b

Browse files
committed
impl. MySQL
1 parent 6ba8abe commit 3a0203b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/mutex/MySQLMutex.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,15 @@ public function lock(): void
4343
{
4444
$statement = $this->pdo->prepare('SELECT GET_LOCK(?,?)');
4545

46+
// MySQL rounds the value to whole seconds, sadly rounds, not ceils
47+
// TODO MariaDB supports microseconds precision since 10.1.2 version,
48+
// but we need to detect the support reliably first
49+
// https://github.com/MariaDB/server/commit/3e792e6cbccb5d7bf5b84b38336f8a40ad232020
50+
$timeoutInt = (int) ceil($this->timeout);
51+
4652
$statement->execute([
4753
$this->name,
48-
$this->timeout,
54+
$timeoutInt,
4955
]);
5056

5157
$statement->setFetchMode(\PDO::FETCH_NUM);

0 commit comments

Comments
 (0)