示例#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();
 }
示例#2
0
文件: Model.php 项目: JoeHorn/piwik
 protected function acquireArchiveTableLock($dbLockName)
 {
     if (Db::getDbLock($dbLockName, $maxRetries = 30) === false) {
         throw new Exception("Cannot get named lock {$dbLockName}.");
     }
 }
 protected function acquireArchiveTableLock()
 {
     $dbLockName = $this->getArchiveLockName();
     if (Db::getDbLock($dbLockName, $maxRetries = 30) === false) {
         throw new Exception("allocateNewArchiveId: Cannot get named lock {$dbLockName}.");
     }
 }