当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Search_Lucene_LockManager::obtainReadLock方法代码示例

本文整理汇总了PHP中Zend_Search_Lucene_LockManager::obtainReadLock方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Search_Lucene_LockManager::obtainReadLock方法的具体用法?PHP Zend_Search_Lucene_LockManager::obtainReadLock怎么用?PHP Zend_Search_Lucene_LockManager::obtainReadLock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Search_Lucene_LockManager的用法示例。


在下文中一共展示了Zend_Search_Lucene_LockManager::obtainReadLock方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct($directory = null, $create = false)
 {
     if ($directory === null) {
         require_once 'Zend/Search/Lucene/Exception.php';
         throw new Zend_Search_Exception('No index directory specified');
     }
     if ($directory instanceof Zend_Search_Lucene_Storage_Directory_Filesystem) {
         $this->_directory = $directory;
         $this->_closeDirOnExit = false;
     } else {
         $this->_directory = new Zend_Search_Lucene_Storage_Directory_Filesystem($directory);
         $this->_closeDirOnExit = true;
     }
     $this->_segmentInfos = array();
     // Mark index as "under processing" to prevent other processes from premature index cleaning
     Zend_Search_Lucene_LockManager::obtainReadLock($this->_directory);
     $this->_generation = self::getActualGeneration($this->_directory);
     if ($create) {
         require_once 'Zend/Search/Lucene/Exception.php';
         try {
             Zend_Search_Lucene_LockManager::obtainWriteLock($this->_directory);
         } catch (Zend_Search_Lucene_Exception $e) {
             Zend_Search_Lucene_LockManager::releaseReadLock($this->_directory);
             if (strpos($e->getMessage(), 'Can\'t obtain exclusive index lock') === false) {
                 throw $e;
             } else {
                 throw new Zend_Search_Lucene_Exception('Can\'t create index. It\'s under processing now');
             }
         }
         if ($this->_generation == -1) {
             // Directory doesn't contain existing index, start from 1
             $this->_generation = 1;
             $nameCounter = 0;
         } else {
             // Directory contains existing index
             $segmentsFile = $this->_directory->getFileObject(self::getSegmentFileName($this->_generation));
             $segmentsFile->seek(12);
             // 12 = 4 (int, file format marker) + 8 (long, index version)
             $nameCounter = $segmentsFile->readInt();
             $this->_generation++;
         }
         Zend_Search_Lucene_Index_Writer::createIndex($this->_directory, $this->_generation, $nameCounter);
         Zend_Search_Lucene_LockManager::releaseWriteLock($this->_directory);
     }
     if ($this->_generation == -1) {
         require_once 'Zend/Search/Lucene/Exception.php';
         throw new Zend_Search_Lucene_Exception('Index doesn\'t exists in the specified directory.');
     } else {
         if ($this->_generation == 0) {
             $this->_readPre21SegmentsFile();
         } else {
             $this->_readSegmentsFile();
         }
     }
 }
开发者ID:hackingman,项目名称:TubeX,代码行数:55,代码来源:Lucene.php

示例2: __construct

 public function __construct($directory = null, $create = false)
 {
     if ($directory === null) {
         throw new Zend_Search_Exception('No index directory specified');
     }
     if (is_string($directory)) {
         $this->_directory = new Zend_Search_Lucene_Storage_Directory_Filesystem($directory);
         $this->_closeDirOnExit = true;
     } else {
         $this->_directory = $directory;
         $this->_closeDirOnExit = false;
     }
     $this->_segmentInfos = array();
     Zend_Search_Lucene_LockManager::obtainReadLock($this->_directory);
     $this->_generation = self::getActualGeneration($this->_directory);
     if ($create) {
         try {
             Zend_Search_Lucene_LockManager::obtainWriteLock($this->_directory);
         } catch (Zend_Search_Lucene_Exception $e) {
             Zend_Search_Lucene_LockManager::releaseReadLock($this->_directory);
             if (strpos($e->getMessage(), 'Can\'t obtain exclusive index lock') === false) {
                 throw new Zend_Search_Lucene_Exception($e->getMessage(), $e->getCode(), $e);
             } else {
                 throw new Zend_Search_Lucene_Exception('Can\'t create index. It\'s under processing now', 0, $e);
             }
         }
         if ($this->_generation == -1) {
             $this->_generation = 1;
             $nameCounter = 0;
         } else {
             $segmentsFile = $this->_directory->getFileObject(self::getSegmentFileName($this->_generation));
             $segmentsFile->seek(12);
             $nameCounter = $segmentsFile->readInt();
             $this->_generation++;
         }
         Zend_Search_Lucene_Index_Writer::createIndex($this->_directory, $this->_generation, $nameCounter);
         Zend_Search_Lucene_LockManager::releaseWriteLock($this->_directory);
     }
     if ($this->_generation == -1) {
         throw new Zend_Search_Lucene_Exception('Index doesn\'t exists in the specified directory.');
     } else {
         if ($this->_generation == 0) {
             $this->_readPre21SegmentsFile();
         } else {
             $this->_readSegmentsFile();
         }
     }
 }
开发者ID:Blu2z,项目名称:implsk,代码行数:48,代码来源:Zend_Search_Lucene.php


注:本文中的Zend_Search_Lucene_LockManager::obtainReadLock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。