public function bootstrap($microtime)
{
try {
try {
$options = $this->forVendor(["mysql" => "ENGINE=InnoDB CHARSET=utf8"]);
$this->pdo->exec("CREATE TABLE TokenBucket (\n name VARCHAR(128) PRIMARY KEY,\n microtime DOUBLE PRECISION NOT NULL\n ) {$options};");
} catch (\PDOException $e) {
/*
* This exception is ignored to provide a portable way
* to create a table only if it doesn't exist yet.
*/
}
$insert = $this->pdo->prepare("INSERT INTO TokenBucket (name, microtime) VALUES (?, ?)");
$insert->execute([$this->name, $microtime]);
if ($insert->rowCount() !== 1) {
throw new StorageException("Failed to insert token bucket into storage '{$this->name}'");
}
} catch (\PDOException $e) {
throw new StorageException("Failed to bootstrap storage '{$this->name}'", 0, $e);
}
}