original_string: 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 . 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;
  	}
code: 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 . 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;
  	}
code_tokens: 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 . 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 ; }
docstring: 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
docstring_tokens: caches the provided output into the cache file