_connection = $resource->getConnection('index_write', 'default_lock'); $this->_helper = Mage::getResourceHelper('index'); } protected function _prepareLockName($name) { $config = $this->_connection->getConfig(); return $config['dbname'] . '.' . $name; } /** * Set named lock * * @param string $lockName * @return int */ public function setLock($lockName) { $lockName = $this->_prepareLockName($lockName); return $this->_helper->setLock($lockName); } /** * Release named lock * * @param string $lockName * @return int|null */ public function releaseLock($lockName) { $lockName = $this->_prepareLockName($lockName); return $this->_helper->releaseLock($lockName); } /** * Check whether the lock exists * * @param string $lockName * @return bool */ public function isLockExists($lockName) { $lockName = $this->_prepareLockName($lockName); return $this->_helper->isLocked($lockName); } }