本文整理汇总了PHP中apc_compile_file函数的典型用法代码示例。如果您正苦于以下问题:PHP apc_compile_file函数的具体用法?PHP apc_compile_file怎么用?PHP apc_compile_file使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了apc_compile_file函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: compileScripts
public function compileScripts()
{
if (!extension_loaded('apc')) {
return;
}
$files = array();
foreach ($this->_refresh_rules as $rules) {
$rules = (object) $rules;
$files = array_merge($files, File::getFilesFromDirectory($rules->dir, $rules->extension, $rules->recursive));
}
foreach ($files as $file) {
if (!$this->isFileCached($file)) {
if ($d = \apc_delete_file($file)) {
Logger::debug('Elimino dalla cache lo script ' . $file . ' per ricompilarlo', RENDER_CORE_LOGNAME);
} else {
Logger::debug('Non sono riuscito ad eliminare ' . $file . ' ' . print_r($d, true));
}
if ($d = \apc_compile_file($file)) {
Logger::debug('Ho compilato lo script ' . $file, 'core');
} else {
Logger::debug('Non sono riuscito a compilare ' . $file . ' ' . print_r($d, true), 'core');
}
}
}
}
示例2: compile
public function compile($filename, $atomic = true)
{
if (CACHE_STATUS) {
apc_compile_file($filename, $atomic);
}
return false;
}
示例3: write
/**
* {@inheritdoc}
*/
public function write($key, $content)
{
$dir = dirname($key);
if (!is_dir($dir)) {
if (false === @mkdir($dir, 0777, true)) {
clearstatcache(false, $dir);
if (!is_dir($dir)) {
throw new RuntimeException(sprintf('Unable to create the cache directory (%s).', $dir));
}
}
} elseif (!is_writable($dir)) {
throw new RuntimeException(sprintf('Unable to write in the cache directory (%s).', $dir));
}
$tmpFile = tempnam($dir, basename($key));
if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $key)) {
@chmod($key, 0666 & ~umask());
if (self::FORCE_BYTECODE_INVALIDATION == ($this->options & self::FORCE_BYTECODE_INVALIDATION)) {
// Compile cached file into bytecode cache
if (function_exists('opcache_invalidate')) {
opcache_invalidate($key, true);
} elseif (function_exists('apc_compile_file')) {
apc_compile_file($key);
}
}
return;
}
throw new RuntimeException(sprintf('Failed to write cache file "%s".', $key));
}
示例4: save
/**
* Formats the output and saved it to disc.
*
* @param string $identifier filename
* @param $contents $contents language array to save
* @return bool \File::update result
*/
public function save($identifier, $contents)
{
// store the current filename
$file = $this->file;
// save it
$return = parent::save($identifier, $contents);
// existing file? saved? and do we need to flush the opcode cache?
if ($file == $this->file and $return and static::$flush_needed) {
if ($this->file[0] !== '/' and (!isset($this->file[1]) or $this->file[1] !== ':')) {
// locate the file
if ($pos = strripos($identifier, '::')) {
// get the namespace path
if ($file = \Autoloader::namespace_path('\\' . ucfirst(substr($identifier, 0, $pos)))) {
// strip the namespace from the filename
$identifier = substr($identifier, $pos + 2);
// strip the classes directory as we need the module root
$file = substr($file, 0, -8) . 'lang' . DS . $identifier;
} else {
// invalid namespace requested
return false;
}
} else {
$file = \Finder::search('lang', $identifier);
}
}
// make sure we have a fallback
$file or $file = APPPATH . 'lang' . DS . $identifier;
// flush the opcode caches that are active
static::$uses_opcache and opcache_invalidate($file, true);
static::$uses_apc and apc_compile_file($file);
}
return $return;
}
示例5: compile
public function compile($filename, $atomic = TRUE)
{
if (_cacheStatus) {
apc_compile_file($filename, $atomic);
}
return FALSE;
}
示例6: flush_file
public function flush_file($filename)
{
if (file_exists($filename)) {
} else {
if (file_exists(ABSPATH . $filename)) {
$filename = ABSPATH . DIRECTORY_SEPARATOR . $filename;
} elseif (file_exists(WP_CONTENT_DIR . DIRECTORY_SEPARATOR . $filename)) {
$filename = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . $filename;
} elseif (file_exists(WPINC . DIRECTORY_SEPARATOR . $filename)) {
$filename = WPINC . DIRECTORY_SEPARATOR . $filename;
} elseif (file_exists(WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . $filename)) {
$filename = WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . $filename;
} else {
return false;
}
}
if (function_exists('opcache_invalidate')) {
return opcache_invalidate($filename, true);
} else {
if (function_exists('apc_compile_file')) {
return apc_compile_file($filename);
}
}
return false;
}
示例7: writeCacheFile
/**
* write apc-cache()
*
* @param $file
* @param $content
*/
protected function writeCacheFile($file, $content)
{
parent::writeCacheFile($file, $content);
// Compile cached-file into bytecode-cache
if (function_exists('apc_compile_file') === true) {
apc_compile_file($file);
}
}
示例8: RunAPC
/**
* Runs the APC cache to pre-cache the php files
* returns true if all files where cached
*/
public static function RunAPC()
{
if (function_exists('apc_compile_file')) {
$file01 = @apc_compile_file(DUPLICATOR_PLUGIN_PATH . "duplicator.php");
return $file01;
} else {
return false;
}
}
示例9: write
/**
* {@inheritdoc}
*/
public function write($key, $content)
{
$this->filesystem->put($key, $content);
// Compile cached file into bytecode cache
if (function_exists('opcache_invalidate')) {
opcache_invalidate($key, true);
} elseif (function_exists('apc_compile_file')) {
apc_compile_file($key);
}
}
示例10: compile_dir
/**
* Сохраняет каталог в двоичном кэше
*
* @param string $dir_name
* @param bool $recursively
*
* @return bool
*/
public static function compile_dir($dir_name, $recursively = true)
{
$compiled = true;
if ($recursively) {
foreach (glob($dir_name . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR) as $dir) {
$compiled = $compiled && self::compile_dir($dir, $recursively);
}
}
foreach (glob($dir_name . DIRECTORY_SEPARATOR . '*.php') as $file) {
$compiled = $compiled && apc_compile_file($file);
}
return $compiled;
}
示例11: save
/**
* Sets a new dynamic configuration
*
* @param array $config
*/
public static function save($config)
{
$content = "<" . "?php return ";
$content .= var_export($config, true);
$content .= "; ?" . ">";
$configFile = self::getConfigFilePath();
file_put_contents($configFile, $content);
if (function_exists('opcache_invalidate')) {
opcache_reset();
opcache_invalidate($configFile);
}
if (function_exists('apc_compile_file')) {
apc_compile_file($configFile);
}
}
示例12: compile_files
/**
* Compile Files for APC
* The function runs through each directory and
* compiles each *.php file through apc_compile_file
* @param string $dir start directory
* @return void
*/
function compile_files($dir, $exts = array('*.php'))
{
$dirs = glob($dir . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR);
if (is_array($dirs) && count($dirs) > 0) {
while (list(, $v) = each($dirs)) {
compile_files($v, $exts);
}
}
foreach ($exts as $ext) {
echo "\n\n" . 'Compiling ' . $ext . "\n";
$files = glob($dir . DIRECTORY_SEPARATOR . $ext);
if (is_array($files) && count($files) > 0) {
while (list(, $v) = each($files)) {
echo 'Compiling ' . $v . "\n";
apc_compile_file($v);
}
}
}
}
示例13: compile_files
function compile_files($dir)
{
$dirs = glob($dir . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR);
$files = glob($dir . DIRECTORY_SEPARATOR . '*.php');
if (is_array($files) && count($files) > 0) {
while (list(, $v) = each($files)) {
if (apc_compile_file($v)) {
$GLOBALS["COMPILED"] = $GLOBALS["COMPILED"] + 1;
}
}
}
$files = glob($dir . DIRECTORY_SEPARATOR . '*.inc');
if (is_array($files) && count($files) > 0) {
while (list(, $v) = each($files)) {
if (apc_compile_file($v)) {
$GLOBALS["COMPILED"] = $GLOBALS["COMPILED"] + 1;
}
}
}
}
示例14: save
/**
* Formats the output and saved it to disk.
*
* @param $contents $contents config array to save
* @return bool \File::update result
*/
public function save($contents)
{
// store the current filename
$file = $this->file;
// save it
$return = parent::save($contents);
// existing file? saved? and do we need to flush the opcode cache?
if ($file == $this->file and $return and static::$flush_needed) {
if ($this->file[0] !== '/' and (!isset($this->file[1]) or $this->file[1] !== ':')) {
// locate the file
$file = \Finder::search('config', $this->file, $this->ext);
}
// make sure we have a fallback
$file or $file = APPPATH . 'config' . DS . $this->file . $this->ext;
// flush the opcode caches that are active
static::$uses_opcache and opcache_invalidate($file, true);
static::$uses_apc and apc_compile_file($file);
}
return $return;
}
示例15: refreshOpcodeCache
/**
* Refreshes all active opcode caches for the specified file
*
* @param string $path Path to the file
* @return boolean True on success, false on failure
*/
protected static function refreshOpcodeCache($path)
{
try {
// Zend OPcache
if (function_exists('opcache_invalidate')) {
opcache_invalidate($path, true);
}
// Zend Optimizer+
if (function_exists('accelerator_reset')) {
accelerator_reset();
}
// APC
if (function_exists('apc_compile_file') && !ini_get('apc.stat')) {
apc_compile_file($path);
}
// eAccelerator
if (function_exists('eaccelerator_purge') && !ini_get('eaccelerator.check_mtime')) {
@eaccelerator_purge();
}
// XCache
if (function_exists('xcache_count') && !ini_get('xcache.stat')) {
if (($count = xcache_count(XC_TYPE_PHP)) > 0) {
for ($id = 0; $id < $count; $id++) {
xcache_clear_cache(XC_TYPE_PHP, $id);
}
}
}
// WinCache
if (function_exists('wincache_refresh_if_changed')) {
wincache_refresh_if_changed(array($path));
}
} catch (\Exception $exception) {
return false;
}
return true;
}