本文整理汇总了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;
}
示例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;
}