當前位置: 首頁>>代碼示例>>PHP>>正文


PHP eZClusterFileHandler::addGeneratingFile方法代碼示例

本文整理匯總了PHP中eZClusterFileHandler::addGeneratingFile方法的典型用法代碼示例。如果您正苦於以下問題:PHP eZClusterFileHandler::addGeneratingFile方法的具體用法?PHP eZClusterFileHandler::addGeneratingFile怎麽用?PHP eZClusterFileHandler::addGeneratingFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在eZClusterFileHandler的用法示例。


在下文中一共展示了eZClusterFileHandler::addGeneratingFile方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: startCacheGeneration

 /**
  * Starts cache generation for the current file.
  *
  * This is done by creating a file named by the original file name, prefixed
  * with '.generating'.
  *
  * @return bool false if the file is being generated, true if it is not
  */
 public function startCacheGeneration()
 {
     eZDebugSetting::writeDebug('kernel-clustering', "Starting cache generation", "dfs::startCacheGeneration( '{$this->filePath}' )");
     $generatingFilePath = $this->filePath . '.generating';
     try {
         $ret = self::$dbbackend->_startCacheGeneration($this->filePath, $generatingFilePath);
     } catch (RuntimeException $e) {
         eZDebug::writeError($e->getMessage());
         return false;
     }
     // generation granted
     if ($ret['result'] == 'ok') {
         eZClusterFileHandler::addGeneratingFile($this);
         $this->realFilePath = $this->filePath;
         $this->filePath = $generatingFilePath;
         $this->generationStartTimestamp = $ret['mtime'];
         return true;
     } elseif ($ret['result'] == 'ko') {
         return $ret['remaining'];
     } else {
         eZLog::write("An error occured starting cache generation on '{$generatingFilePath}'", 'cluster.log');
         return false;
     }
 }
開發者ID:CG77,項目名稱:ezpublish-legacy,代碼行數:32,代碼來源:ezdfsfilehandler.php

示例2: startCacheGeneration

    /**
     * Starts cache generation for the current file.
     *
     * This is done by creating a file named by the original file name, prefixed
     * with '.generating'.
     *
     * @return bool false if the file is being generated, true if it is not
     */
    public function startCacheGeneration()
    {
        $generatingFilePath = $this->filePath . '.generating';
        $ret = self::$dbbackend->_startCacheGeneration( $this->filePath, $generatingFilePath );

        // generation granted
        if ( $ret['result'] == 'ok' )
        {
            eZClusterFileHandler::addGeneratingFile( $this );
            $this->realFilePath = $this->filePath;
            $this->filePath = $generatingFilePath;
            $this->generationStartTimestamp = $ret['mtime'];
            return true;
        }
        // failure: the file is being generated
        elseif ( $ret['result'] == 'ko' )
        {
            return $ret['remaining'];
        }
        // unhandled error case, should not happen
        else
        {
            eZLog::write( "An error occured starting cache generation on '$generatingFilePath'", 'cluster.log' );
            return false;
        }
    }
開發者ID:nottavi,項目名稱:ezpublish,代碼行數:34,代碼來源:ezdbfilehandler.php

示例3: startCacheGeneration

    /**
     * Starts cache generation for the current file.
     *
     * This is done by creating a file named by the original file name, prefixed
     * with '.generating'.
     *
     * @todo add timeout handling...
     *
     * @return mixed true if generation lock was granted, an integer matching the
     *               time before the current generation times out
     */
    public function startCacheGeneration()
    {
        eZDebugSetting::writeDebug( "kernel-clustering", $this->filePath, __METHOD__ );

        $ret = true;

        $generatingFilePath = $this->filePath . '.generating';

        // the x flag will throw a warning if the file exists. Allows existence
        // check AND creation at the same time
        if ( !$fp = @fopen( $generatingFilePath, 'x' ) )
        {
            $directory = dirname( $generatingFilePath ) . DIRECTORY_SEPARATOR;

            // the directory we're trying to create the file in does not exist
            eZDebugSetting::writeDebug( 'kernel-clustering', $this->filePath . " creation failed, checking if '$directory' exists", __METHOD__ );

            if ( !file_exists( $directory ) )
            {
                eZDebugSetting::writeDebug( 'kernel-clustering', $this->filePath . " target directory does not exist, creating and trying again", __METHOD__ );

                if ( eZDir::mkdir( $directory, false, true ) )
                    eZDebugSetting::writeDebug( 'kernel-clustering', "Directory '$directory' created, trying to start generation again", __METHOD__ );
                else
                    eZDebugSetting::writeDebug( 'kernel-clustering', "Directory '$directory' failed to be created, it might have been created by another process", __METHOD__ );

                // we check again since the folder may have been created by another
                // process in between. Not likely, though.
                if ( !$fp = @fopen( $generatingFilePath, 'x' ) )
                {
                    $ret = $this->remainingCacheGenerationTime( $generatingFilePath );
                }
            }
            // directory exists, we now check for timeout
            else
            {
                // timeout check
                if ( $mtime = @filemtime( $generatingFilePath ) )
                {
                    $remainingGenerationTime = $this->remainingCacheGenerationTime( $generatingFilePath );
                    eZDebugSetting::writeDebug( 'kernel-clustering', "Remaining generation time: $remainingGenerationTime", __METHOD__ );
                    if ( $remainingGenerationTime < 0 )
                    {
                        eZDebugSetting::writeDebug( 'kernel-clustering', $this->filePath . " generating file exists, but generation has timedout, taking over", __METHOD__ );
                        touch( $generatingFilePath, time(), time() );
                    }
                    else
                    {
                        eZDebugSetting::writeDebug( 'kernel-clustering', $this->filePath . " failed opening file for writing, generation is underway", __METHOD__ );
                        $ret = $remainingGenerationTime;
                    }
                }
            }
        }

        // if the generation lock was granted, we can perform our specific file
        // operations: change the file name to the generation name, and store
        // required generating informations
        if ( $ret === true )
        {
            // $fp might not be a valid handle if timeout has occured
            if ( $fp )
                fclose( $fp );

            eZClusterFileHandler::addGeneratingFile( $this );
            $this->realFilePath = $this->filePath;
            $this->filePath = $generatingFilePath;
            $this->generationStartTimestamp = filemtime( $this->filePath );
        }

        return $ret;
    }
開發者ID:nottavi,項目名稱:ezpublish,代碼行數:83,代碼來源:ezfs2filehandler.php

示例4: startCacheGeneration

 /**
  * Starts cache generation for the current file.
  *
  * This is done by creating a file named by the original file name, prefixed
  * with '.generating'.
  *
  * @return bool false if the file is being generated, true if it is not
  **/
 public function startCacheGeneration()
 {
     $generatingFilePath = $this->filePath . '.generating';
     $ret = $this->backend->_startCacheGeneration($this->filePath, $generatingFilePath);
     // generation granted
     if ($ret['result'] == 'ok') {
         eZClusterFileHandler::addGeneratingFile($this);
         $this->realFilePath = $this->filePath;
         $this->filePath = $generatingFilePath;
         $this->generationStartTimestamp = $ret['mtime'];
         return true;
     } elseif ($ret['result'] == 'ko') {
         return $ret['remaining'];
     } else {
         eZLog::write("An error occured starting cache generation on '{$generatingFilePath}'", 'cluster.log');
         return false;
     }
 }
開發者ID:rmiguel,項目名稱:ezpublish,代碼行數:26,代碼來源:ezdbfilehandler.php


注:本文中的eZClusterFileHandler::addGeneratingFile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。