本文整理汇总了PHP中apc_delete_file函数的典型用法代码示例。如果您正苦于以下问题:PHP apc_delete_file函数的具体用法?PHP apc_delete_file怎么用?PHP apc_delete_file使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了apc_delete_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: deleteFile
public function deleteFile($file)
{
if (CACHE_STATUS) {
apc_delete_file($file);
}
return false;
}
示例3: deleteFile
public function deleteFile($file)
{
if (_cacheStatus) {
apc_delete_file($file);
}
return FALSE;
}
示例4: commit
/**
* Writes all configuration to application configuration file
* @return bool result, true if success
*/
public function commit()
{
$data = <<<PHP
<?php
/*
* ! WARNING !
*
* This file is auto-generated.
* Please don't modify it by-hand or all your changes can be lost.
*/
{$this->append}
return
PHP;
$data .= VarDumper::export($this->configuration);
$data .= ";\n\n";
$result = file_put_contents($this->filename, $data, LOCK_EX) !== false;
if ($result) {
if (function_exists('opcache_invalidate')) {
opcache_invalidate($this->filename, true);
}
if (function_exists('apc_delete_file')) {
@apc_delete_file($this->filename);
}
}
return $result;
}
示例5: invalidateScript
public static function invalidateScript($path)
{
if (extension_loaded('Zend OPcache')) {
opcache_invalidate($path);
} elseif (extension_loaded('apc')) {
apc_delete_file($path);
}
}
示例6: invalidateScriptCache
/**
* Invalidates precompiled script cache (such as OPCache or APC) for the given file.
* @param string $fileName file name.
* @since 1.0.2
*/
protected function invalidateScriptCache($fileName)
{
if (function_exists('opcache_invalidate')) {
opcache_invalidate($fileName, true);
}
if (function_exists('apc_delete_file')) {
@apc_delete_file($fileName);
}
}
示例7: flushConfigCache
protected function flushConfigCache()
{
if (extension_loaded('apc')) {
if (function_exists('apc_delete_file')) {
@apc_delete_file(Curry_Core::$config->curry->configPath);
} else {
@apc_clear_cache();
}
}
}
示例8: initialize
/**
* Initialize the cache properties
*/
protected static function initialize()
{
$apcVersion = phpversion('apc');
$xcVersion = phpversion('xcache');
static::$supportedCaches = array('OPcache' => array('active' => extension_loaded('Zend OPcache') && ini_get('opcache.enable') === '1', 'version' => phpversion('Zend OPcache'), 'canReset' => TRUE, 'canInvalidate' => function_exists('opcache_invalidate'), 'error' => FALSE, 'clearCallback' => function ($fileAbsPath) {
if ($fileAbsPath !== NULL && function_exists('opcache_invalidate')) {
opcache_invalidate($fileAbsPath);
} else {
opcache_reset();
}
}), 'APC' => array('active' => extension_loaded('apc') && !extension_loaded('apcu') && ini_get('apc.enabled') === '1', 'version' => $apcVersion, 'canReset' => TRUE, 'canInvalidate' => self::canApcInvalidate(), 'error' => $apcVersion && VersionNumberUtility::convertVersionNumberToInteger($apcVersion) < 3001007, 'clearCallback' => function ($fileAbsPath) {
if ($fileAbsPath !== NULL && OpcodeCacheUtility::getCanInvalidate('APC')) {
// This may output a warning like: PHP Warning: apc_delete_file(): Could not stat file
// This warning isn't true, this means that apc was unable to generate the cache key
// which depends on the configuration of APC.
apc_delete_file($fileAbsPath);
} else {
apc_clear_cache('opcode');
}
}), 'WinCache' => array('active' => extension_loaded('wincache') && ini_get('wincache.ocenabled') === '1', 'version' => phpversion('wincache'), 'canReset' => FALSE, 'canInvalidate' => TRUE, 'error' => FALSE, 'clearCallback' => function ($fileAbsPath) {
if ($fileAbsPath !== NULL) {
wincache_refresh_if_changed(array($fileAbsPath));
} else {
// No argument means refreshing all.
wincache_refresh_if_changed();
}
}), 'XCache' => array('active' => extension_loaded('xcache'), 'version' => $xcVersion, 'canReset' => TRUE, 'canInvalidate' => FALSE, 'error' => FALSE, 'clearCallback' => $xcVersion && VersionNumberUtility::convertVersionNumberToInteger($xcVersion) < 3000000 ? function ($fileAbsPath) {
if (!ini_get('xcache.admin.enable_auth')) {
xcache_clear_cache(XC_TYPE_PHP, 0);
}
} : function ($fileAbsPath) {
if (!ini_get('xcache.admin.enable_auth')) {
xcache_clear_cache(XC_TYPE_PHP);
}
}), 'eAccelerator' => array('active' => extension_loaded('eAccelerator'), 'version' => phpversion('eaccelerator'), 'canReset' => FALSE, 'canInvalidate' => FALSE, 'error' => TRUE, 'clearCallback' => function ($fileAbsPath) {
eaccelerator_clear();
}), 'ZendOptimizerPlus' => array('active' => extension_loaded('Zend Optimizer+') && ini_get('zend_optimizerplus.enable') === '1', 'version' => phpversion('Zend Optimizer+'), 'canReset' => TRUE, 'canInvalidate' => FALSE, 'error' => FALSE, 'clearCallback' => function ($fileAbsPath) {
accelerator_reset();
}));
static::$activeCaches = array();
// Cache the active ones
foreach (static::$supportedCaches as $opcodeCache => $properties) {
if ($properties['active']) {
static::$activeCaches[$opcodeCache] = $properties;
}
}
}
示例9: invalidate
/**
* Invalidates a PHP file from a possibly active opcode cache.
*
* In case the opcode cache does not support to invalidate an individual file,
* the entire cache will be flushed.
*
* @param string $pathname
* The absolute pathname of the PHP file to invalidate.
*/
public static function invalidate($pathname)
{
clearstatcache(TRUE, $pathname);
if (extension_loaded('Zend OPcache')) {
opcache_invalidate($pathname, TRUE);
}
// If apcu extension is enabled in PHP 5.5 or greater it emulates apc.
// This is to provide an easy upgrade path if you are using apc's user
// caching however the emulation does not extend to opcode caching.
// Therefore we need to check if the function exists as well.
if (extension_loaded('apc') && function_exists('apc_delete_file')) {
// apc_delete_file() throws a PHP warning in case the specified file was
// not compiled yet.
// @see http://php.net/manual/en/function.apc-delete-file.php
@apc_delete_file($pathname);
}
}
示例10: actionClearOutdated
public function actionClearOutdated()
{
$cache = apc_cache_info('opcode');
$files = array();
foreach ($cache['cache_list'] as $file) {
if (filemtime($file['filename']) > $file['mtime']) {
$files[] = $file['filename'];
}
}
$result = apc_delete_file($files);
if (empty($result)) {
Yii::app()->user->setFlash('success', count($files) . ' outdated cache files cleared.');
} else {
Yii::app()->user->setFlash('error', 'Puriging the following files from the cache has failed: ' . implode(', ', $result));
}
$this->redirect(array('index', '#' => 'fileCache'));
}
示例11: initialize
/**
* Initialize the cache properties
*
* @return void
*/
protected static function initialize()
{
$apcVersion = phpversion('apc');
$xcVersion = phpversion('xcache');
static::$supportedCaches = array('OPcache' => array('active' => extension_loaded('Zend OPcache') && ini_get('opcache.enable') === '1', 'version' => phpversion('Zend OPcache'), 'canReset' => true, 'canInvalidate' => function_exists('opcache_invalidate'), 'error' => false, 'clearCallback' => function ($fileAbsPath) {
if ($fileAbsPath !== null && function_exists('opcache_invalidate')) {
opcache_invalidate($fileAbsPath, true);
} else {
opcache_reset();
}
}), 'APC' => array('active' => extension_loaded('apc') && !extension_loaded('apcu') && ini_get('apc.enabled') === '1', 'version' => $apcVersion, 'canReset' => true, 'canInvalidate' => self::canApcInvalidate(), 'error' => $apcVersion && version_compare($apcVersion, '3.1.7', '<'), 'clearCallback' => function ($fileAbsPath) {
if ($fileAbsPath !== null && iMSCP_Utility_OpcodeCache::getCanInvalidate('APC')) {
// This may output a warning like: PHP Warning: apc_delete_file(): Could not stat file
// This warning isn't true, this means that apc was unable to generate the cache key
// which depends on the configuration of APC.
@apc_delete_file($fileAbsPath);
} else {
apc_clear_cache('opcode');
}
}), 'XCache' => array('active' => extension_loaded('xcache'), 'version' => $xcVersion, 'canReset' => true, 'canInvalidate' => false, 'error' => false, 'clearCallback' => $xcVersion && version_compare($xcVersion, '3.0.0', '<') ? function () {
if (!ini_get('xcache.admin.enable_auth')) {
xcache_clear_cache(XC_TYPE_PHP, 0);
}
} : function () {
if (!ini_get('xcache.admin.enable_auth')) {
xcache_clear_cache(XC_TYPE_PHP);
}
}), 'eAccelerator' => array('active' => extension_loaded('eAccelerator'), 'version' => phpversion('eaccelerator'), 'canReset' => false, 'canInvalidate' => false, 'error' => false, 'clearCallback' => function () {
eaccelerator_clear();
}), 'ZendOptimizerPlus' => array('active' => extension_loaded('Zend Optimizer+') && ini_get('zend_optimizerplus.enable') === '1', 'version' => phpversion('Zend Optimizer+'), 'canReset' => true, 'canInvalidate' => false, 'error' => false, 'clearCallback' => function () {
accelerator_reset();
}));
static::$activeCaches = array();
// Cache the active ones
foreach (static::$supportedCaches as $opcodeCache => $properties) {
if ($properties['active']) {
static::$activeCaches[$opcodeCache] = $properties;
}
}
}
示例12: clearApc
protected function clearApc()
{
$console = $this->getConsole();
if (!(bool) ini_get('apc.enable_cli')) {
$console->writeLine('You must enable APC in CLI before clearing APC cache', Color::RED);
$console->writeLine('Check the "apc.enable_cli" setting in your php.ini (see http://www.php.net/apc.configuration)');
return;
}
$info = array_keys(apc_cache_info());
$scripts = $info['cache_list'];
if (count($scripts) === 0) {
$console->writeLine('No files cached in APC, aborting', Color::RED);
return;
}
array_map(function ($value) {
return $value['filename'];
}, $scripts);
$results = apc_delete_file($scripts);
foreach ($results as $result) {
$console->writeLine('Failed to clear opcode cache for ' . $result, Color::RED);
}
$console->writeLine(sprintf('%s APC files cleared', count($scripts)), Color::GREEN);
}
示例13: showMain
/** {@inheritdoc} */
public function showMain()
{
if (!is_writable(Curry_Core::$config->curry->configPath)) {
$this->addMessage("Configuration file doesn't seem to be writable.", self::MSG_ERROR);
}
$config = new Zend_Config(require Curry_Core::$config->curry->configPath, true);
$pages = PagePeer::getSelect();
$form = new Curry_Form(array('action' => url('', array("module", "view")), 'method' => 'post', 'elements' => array('enabled' => array('checkbox', array('label' => 'Enable domain mapping', 'value' => $config->curry->domainMapping->enabled)), 'default_base_page' => array('select', array('label' => 'Default base page', 'description' => 'The default base page will only be used if there are no other domains matching and domain mapping is enabled', 'value' => $config->curry->domainMapping->default, 'multiOptions' => array('' => '[ None ]') + $pages)))));
$domainForm = new Curry_Form_Dynamic(array('legend' => 'Domain', 'elements' => array('domain' => array('text', array('label' => 'Domain', 'description' => 'You can use default as a wildcard to fetch unmatched domains.', 'required' => true)), 'base_page' => array('select', array('label' => 'Base page', 'multiOptions' => array('' => '[ None ]') + $pages, 'required' => true)), 'include_www' => array('checkbox', array('label' => 'Include www')))));
$form->addSubForm(new Curry_Form_MultiForm(array('legend' => '', 'cloneTarget' => $domainForm, 'defaults' => $config->curry->domainMapping->domains ? $config->curry->domainMapping->domains->toArray() : array())), 'domainMapping');
$form->addElement('submit', 'save', array('label' => 'Save'));
if (isPost() && $form->isValid($_POST)) {
$values = $form->getValues();
if (!$config->curry->domainMapping) {
$config->curry->domainMapping = array();
}
$config->curry->domainMapping->enabled = count($values['domainMapping']) ? (bool) $values['enabled'] : false;
$config->curry->domainMapping->default = $values['default_base_page'];
$config->curry->domainMapping->domains = $values['domainMapping'];
try {
$writer = new Zend_Config_Writer_Array();
$writer->write(Curry_Core::$config->curry->configPath, $config);
if (extension_loaded('apc')) {
if (function_exists('apc_delete_file')) {
@apc_delete_file(Curry_Core::$config->curry->configPath);
} else {
@apc_clear_cache();
}
}
$this->addMessage("Settings saved.", self::MSG_SUCCESS);
} catch (Exception $e) {
$this->addMessage($e->getMessage(), self::MSG_ERROR);
}
}
$this->addMainContent($form);
}
示例14: clear_feed_cache
public function clear_feed_cache()
{
$d = dir($this->feather->forum_env['FORUM_CACHE_DIR']);
$d = $this->hook->fire('options.clear_feed_cache.directory', $d);
while (($entry = $d->read()) !== false) {
if (substr($entry, 0, 10) == 'cache_feed' && substr($entry, -4) == '.php') {
@unlink($this->feather->forum_env['FORUM_CACHE_DIR'] . $entry);
}
if (function_exists('opcache_invalidate')) {
opcache_invalidate($this->feather->forum_env['FORUM_CACHE_DIR'] . $entry, true);
} elseif (function_exists('apc_delete_file')) {
@apc_delete_file($this->feather->forum_env['FORUM_CACHE_DIR'] . $entry);
}
}
$d->close();
}
示例15: save
/**
*
*
* @return bool|null
* @throws Exception
*/
public function save()
{
if (!$this->Dirty) {
return null;
}
$this->EventArguments['ConfigDirty'] =& $this->Dirty;
$this->EventArguments['ConfigNoSave'] = false;
$this->EventArguments['ConfigType'] = $this->Type;
$this->EventArguments['ConfigSource'] = $this->Source;
$this->EventArguments['ConfigData'] = $this->Settings;
$this->fireEvent('BeforeSave');
if ($this->EventArguments['ConfigNoSave']) {
$this->Dirty = false;
return true;
}
// Check for and fire callback if one exists
if ($this->Callback && is_callable($this->Callback)) {
$CallbackOptions = array();
if (!is_array($this->CallbackOptions)) {
$this->CallbackOptions = array();
}
$CallbackOptions = array_merge($CallbackOptions, $this->CallbackOptions, array('ConfigDirty' => $this->Dirty, 'ConfigType' => $this->Type, 'ConfigSource' => $this->Source, 'ConfigData' => $this->Settings, 'SourceObject' => $this));
$ConfigSaved = call_user_func($this->Callback, $CallbackOptions);
if ($ConfigSaved) {
$this->Dirty = false;
return true;
}
}
switch ($this->Type) {
case 'file':
if (empty($this->Source)) {
trigger_error(errorMessage('You must specify a file path to be saved.', 'Configuration', 'Save'), E_USER_ERROR);
}
$CheckWrite = $this->Source;
if (!file_exists($CheckWrite)) {
$CheckWrite = dirname($CheckWrite);
}
if (!is_writable($CheckWrite)) {
throw new Exception(sprintf(t("Unable to write to config file '%s' when saving."), $this->Source));
}
$Group = $this->Group;
$Data =& $this->Settings;
ksort($Data);
// Check for the case when the configuration is the group.
if (is_array($Data) && count($Data) == 1 && array_key_exists($Group, $Data)) {
$Data = $Data[$Group];
}
// Do a sanity check on the config save.
if ($this->Source == Gdn::config()->defaultPath()) {
// Log root config changes
try {
$LogData = $this->Initial;
$LogData['_New'] = $this->Settings;
LogModel::insert('Edit', 'Configuration', $LogData);
} catch (Exception $Ex) {
}
if (!isset($Data['Database'])) {
if ($Pm = Gdn::pluginManager()) {
$Pm->EventArguments['Data'] = $Data;
$Pm->EventArguments['Backtrace'] = debug_backtrace();
$Pm->fireEvent('ConfigError');
}
return false;
}
}
// Write config data to string format, ready for saving
$FileContents = Gdn_Configuration::format($Data, array('VariableName' => $Group, 'WrapPHP' => true, 'ByLine' => true));
if ($FileContents === false) {
trigger_error(errorMessage('Failed to define configuration file contents.', 'Configuration', 'Save'), E_USER_ERROR);
}
// Save to cache if we're into that sort of thing
$FileKey = sprintf(Gdn_Configuration::CONFIG_FILE_CACHE_KEY, $this->Source);
if ($this->Configuration && $this->Configuration->caching() && Gdn::cache()->type() == Gdn_Cache::CACHE_TYPE_MEMORY && Gdn::cache()->activeEnabled()) {
$CachedConfigData = Gdn::cache()->store($FileKey, $Data, array(Gdn_Cache::FEATURE_NOPREFIX => true, Gdn_Cache::FEATURE_EXPIRY => 3600));
}
$TmpFile = tempnam(PATH_CONF, 'config');
$Result = false;
if (file_put_contents($TmpFile, $FileContents) !== false) {
chmod($TmpFile, 0775);
$Result = rename($TmpFile, $this->Source);
}
if ($Result) {
if (function_exists('apc_delete_file')) {
// This fixes a bug with some configurations of apc.
@apc_delete_file($this->Source);
} elseif (function_exists('opcache_invalidate')) {
@opcache_invalidate($this->Source);
}
}
$this->Dirty = false;
return $Result;
break;
case 'json':
case 'array':
//.........这里部分代码省略.........