/**
* Creates a table {prefix}{$namespace}_lock that is used as a mutex.
*
* @param string $namespace Allows having separate locks for separate processes
* @return bool
*/
public function lock($namespace)
{
$this->assertNamespace($namespace);
if (!$this->isLocked($namespace)) {
// Lock it
$this->db->insertData("CREATE TABLE {$this->db->getTablePrefix()}{$namespace}_lock (id INT)");
$this->logger->info("Locked mutex for {$namespace}");
return true;
}
$this->logger->warn("Cannot lock mutex for {$namespace}: already locked.");
return false;
}