当前位置: 首页>>代码示例>>PHP>>正文


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怎么用?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.');
     }
 }
开发者ID:eamador,项目名称:moodle-course-custom-fields,代码行数:49,代码来源:locallib.php


注:本文中的core_component::invalidate_opcode_php_cache方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。