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


PHP Dwoo::getCacheDir方法代碼示例

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


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

示例1: cache

 /**
  * caches the provided output into the cache file
  *
  * @param Dwoo $dwoo the dwoo instance that requests it
  * @param string $output the template output
  * @return mixed full path of the cached file or false upon failure
  */
 public function cache(Dwoo $dwoo, $output)
 {
     $cacheDir = $dwoo->getCacheDir();
     $cachedFile = $this->getCacheFilename($dwoo);
     // the code below is courtesy of Rasmus Schultz,
     // thanks for his help on avoiding concurency issues
     $temp = tempnam($cacheDir, 'temp');
     if (!($file = @fopen($temp, 'wb'))) {
         $temp = $cacheDir . DIRECTORY_SEPARATOR . uniqid('temp');
         if (!($file = @fopen($temp, 'wb'))) {
             trigger_error('Error writing temporary file \'' . $temp . '\'', E_USER_WARNING);
             return false;
         }
     }
     fwrite($file, $output);
     fclose($file);
     $this->makeDirectory(dirname($cachedFile));
     if (!@rename($temp, $cachedFile)) {
         @unlink($cachedFile);
         @rename($temp, $cachedFile);
     }
     if ($this->chmod !== null) {
         chmod($cachedFile, $this->chmod);
     }
     self::$cache['cached'][$this->cacheId] = true;
     return $cachedFile;
 }
開發者ID:apeschar,項目名稱:php-fw,代碼行數:34,代碼來源:String.php

示例2: cache

 public function cache(Dwoo $dwoo, $output)
 {
     $cacheDir = $dwoo->getCacheDir();
     $cachedFile = $this->getCacheFilename($dwoo);
     $temp = tempnam($cacheDir, 'temp');
     if (!($file = @fopen($temp, 'wb'))) {
         $temp = $cacheDir . uniqid('temp');
         if (!($file = @fopen($temp, 'wb'))) {
             trigger_error('Error writing temporary file \'' . $temp . '\'', E_USER_WARNING);
             return false;
         }
     }
     fwrite($file, $output);
     fclose($file);
     $this->makeDirectory(dirname($cachedFile), $cacheDir);
     if (!@rename($temp, $cachedFile)) {
         @unlink($cachedFile);
         @rename($temp, $cachedFile);
     }
     if ($this->chmod !== null) {
         chmod($cachedFile, $this->chmod);
     }
     self::$cache['cached'][$this->cacheId] = true;
     return $cachedFile;
 }
開發者ID:janaece,項目名稱:globalclassroom4_clean,代碼行數:25,代碼來源:Dwoo.compiled.php


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