Skip to content

Commit

Permalink
#2189 OPcache 무효화 및 status cache 초기화를 수행하는 메소드 추가
Browse files Browse the repository at this point in the history
- FileHandler::clearStatCache() : 지정한 파일 또는 디렉토리의 파일의 status cache 초기화
- FileHandler::invalidateOpcache() : 지정한 파일 또는 디렉토리의 파일의 OPcache 무효화
  • Loading branch information
bnu committed Dec 6, 2017
1 parent 1a852bf commit 23ec7b7
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions classes/file/FileHandler.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,66 @@ function isWritableDir($path)
self::removeFile($checkFile);
return TRUE;
}

/**
* Clears file status cache
*
* @param string|array $target filename or directory
* @param boolean $include include files in the directory
**/
static public function clearStatCache($target, $include = false)
{
if(is_array($target))
{
array_map('self::clearStatCache', $target);
return;
}

$target = self:getRealPath($target);

if($include && self::isDir($target))
{
self::clearStatCache(self::readDir($target, '', false, true), $include);
}

clearstatcache(true, $target);
}

/**
* Invalidates a cached script of OPcache
*
* @param string|array $target filename or directory
* @param boolean $force force
**/
static public function invalidateOpcache($target, $force = true)
{
static $opcache = null;

if($opcache === null)
{
$opcache = (function_exists('opcache_get_status') && function_exists('opcache_invalidate'));
}

if($opcache === false)
{
return;
}

if(is_array($target))
{
array_map('self::invalidateOpcache', $target);
return;
}

if(substr($target, -4) === '.php')
{
opcache_invalidate(self::getRealPath($target), $force);
}
else if($path = self::isDir($target))
{
self::invalidateOpcache(self::readDir($path, '', false, true));
}
}
}

/* End of file FileHandler.class.php */
Expand Down

0 comments on commit 23ec7b7

Please sign in to comment.