Exemplo n.º 1
0
 public function test_getDbLock_shouldGetLock()
 {
     $db = Db::get();
     $this->assertTrue(Db::getDbLock('MyLock'));
     // same session still has lock
     $this->assertTrue(Db::getDbLock('MyLock'));
     Db::setDatabaseObject(null);
     // different session, should not be able to acquire lock
     $this->assertFalse(Db::getDbLock('MyLock', 1));
     // different session cannot release lock
     $this->assertFalse(Db::releaseDbLock('MyLock'));
     Db::destroyDatabaseObject();
     // release lock again by using previous session
     Db::setDatabaseObject($db);
     $this->assertTrue(Db::releaseDbLock('MyLock'));
     Db::destroyDatabaseObject();
 }
Exemplo n.º 2
0
 protected function acquireArchiveTableLock($dbLockName)
 {
     if (Db::getDbLock($dbLockName, $maxRetries = 30) === false) {
         throw new Exception("Cannot get named lock {$dbLockName}.");
     }
 }
Exemplo n.º 3
0
 protected function acquireArchiveTableLock()
 {
     $dbLockName = $this->getArchiveLockName();
     if (Db::getDbLock($dbLockName, $maxRetries = 30) === false) {
         throw new Exception("allocateNewArchiveId: Cannot get named lock {$dbLockName}.");
     }
 }