本文整理汇总了PHP中core_component::invalidate_opcode_php_cache方法的典型用法代码示例。如果您正苦于以下问题:PHP core_component::invalidate_opcode_php_cache方法的具体用法?PHP core_component::invalidate_opcode_php_cache怎么用?PHP core_component::invalidate_opcode_php_cache使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_component
的用法示例。
在下文中一共展示了core_component::invalidate_opcode_php_cache方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: config_save
/**
* Saves the current configuration.
*
* Exceptions within this function are tolerated but must be of type cache_exception.
* They are caught during initialisation and written to the error log. This is required in order to avoid
* infinite loop situations caused by the cache throwing exceptions during its initialisation.
*/
protected function config_save()
{
global $CFG;
$cachefile = self::get_config_file_path();
$directory = dirname($cachefile);
if ($directory !== $CFG->dataroot && !file_exists($directory)) {
$result = make_writable_directory($directory, false);
if (!$result) {
throw new cache_exception('ex_configcannotsave', 'cache', '', null, 'Cannot create config directory. Check the permissions on your moodledata directory.');
}
}
if (!file_exists($directory) || !is_writable($directory)) {
throw new cache_exception('ex_configcannotsave', 'cache', '', null, 'Config directory is not writable. Check the permissions on the moodledata/muc directory.');
}
// Prepare a configuration array to store.
$configuration = $this->generate_configuration_array();
// Prepare the file content.
$content = "<?php defined('MOODLE_INTERNAL') || die();\n \$configuration = " . var_export($configuration, true) . ";";
// We need to create a temporary cache lock instance for use here. Remember we are generating the config file
// it doesn't exist and thus we can't use the normal API for this (it'll just try to use config).
$lockconf = reset($this->configlocks);
if ($lockconf === false) {
debugging('Your cache configuration file is out of date and needs to be refreshed.', DEBUG_DEVELOPER);
// Use the default
$lockconf = array('name' => 'cachelock_file_default', 'type' => 'cachelock_file', 'dir' => 'filelocks', 'default' => true);
}
$factory = cache_factory::instance();
$locking = $factory->create_lock_instance($lockconf);
if ($locking->lock('configwrite', 'config', true)) {
// Its safe to use w mode here because we have already acquired the lock.
$handle = fopen($cachefile, 'w');
fwrite($handle, $content);
fflush($handle);
fclose($handle);
$locking->unlock('configwrite', 'config');
@chmod($cachefile, $CFG->filepermissions);
// Tell PHP to recompile the script.
core_component::invalidate_opcode_php_cache($cachefile);
} else {
throw new cache_exception('ex_configcannotsave', 'cache', '', null, 'Unable to open the cache config file.');
}
}