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


PHP cache_factory::disable_stores方法代码示例

本文整理汇总了PHP中cache_factory::disable_stores方法的典型用法代码示例。如果您正苦于以下问题:PHP cache_factory::disable_stores方法的具体用法?PHP cache_factory::disable_stores怎么用?PHP cache_factory::disable_stores使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cache_factory的用法示例。


在下文中一共展示了cache_factory::disable_stores方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: test_disable_stores

 /**
  * Test disabling the cache stores.
  */
 public function test_disable_stores()
 {
     $instance = cache_config_phpunittest::instance();
     $instance->phpunit_add_definition('phpunit/disabletest', array('mode' => cache_store::MODE_APPLICATION, 'component' => 'phpunit', 'area' => 'disabletest'));
     $cache = cache::make('phpunit', 'disabletest');
     $this->assertInstanceOf('cache_phpunit_application', $cache);
     $this->assertEquals('cachestore_file', $cache->phpunit_get_store_class());
     $this->assertFalse($cache->get('test'));
     $this->assertTrue($cache->set('test', 'test'));
     $this->assertEquals('test', $cache->get('test'));
     cache_factory::disable_stores();
     $cache = cache::make('phpunit', 'disabletest');
     $this->assertInstanceOf('cache_phpunit_application', $cache);
     $this->assertEquals('cachestore_dummy', $cache->phpunit_get_store_class());
     $this->assertFalse($cache->get('test'));
     $this->assertTrue($cache->set('test', 'test'));
     $this->assertEquals('test', $cache->get('test'));
 }
开发者ID:Burick,项目名称:moodle,代码行数:21,代码来源:cache_test.php

示例2: test_disable_stores

 /**
  * Test disabling the cache stores.
  */
 public function test_disable_stores()
 {
     $instance = cache_config_testing::instance();
     $instance->phpunit_add_definition('phpunit/disabletest1', array('mode' => cache_store::MODE_APPLICATION, 'component' => 'phpunit', 'area' => 'disabletest1'));
     $instance->phpunit_add_definition('phpunit/disabletest2', array('mode' => cache_store::MODE_SESSION, 'component' => 'phpunit', 'area' => 'disabletest2'));
     $instance->phpunit_add_definition('phpunit/disabletest3', array('mode' => cache_store::MODE_REQUEST, 'component' => 'phpunit', 'area' => 'disabletest3'));
     $caches = array('disabletest1' => cache::make('phpunit', 'disabletest1'), 'disabletest2' => cache::make('phpunit', 'disabletest2'), 'disabletest3' => cache::make('phpunit', 'disabletest3'));
     $this->assertInstanceOf('cache_phpunit_application', $caches['disabletest1']);
     $this->assertInstanceOf('cache_phpunit_session', $caches['disabletest2']);
     $this->assertInstanceOf('cache_phpunit_request', $caches['disabletest3']);
     $this->assertEquals('cachestore_file', $caches['disabletest1']->phpunit_get_store_class());
     $this->assertEquals('cachestore_session', $caches['disabletest2']->phpunit_get_store_class());
     $this->assertEquals('cachestore_static', $caches['disabletest3']->phpunit_get_store_class());
     foreach ($caches as $cache) {
         $this->assertFalse($cache->get('test'));
         $this->assertTrue($cache->set('test', 'test'));
         $this->assertEquals('test', $cache->get('test'));
     }
     cache_factory::disable_stores();
     $caches = array('disabletest1' => cache::make('phpunit', 'disabletest1'), 'disabletest2' => cache::make('phpunit', 'disabletest2'), 'disabletest3' => cache::make('phpunit', 'disabletest3'));
     $this->assertInstanceOf('cache_phpunit_application', $caches['disabletest1']);
     $this->assertInstanceOf('cache_phpunit_session', $caches['disabletest2']);
     $this->assertInstanceOf('cache_phpunit_request', $caches['disabletest3']);
     $this->assertEquals('cachestore_dummy', $caches['disabletest1']->phpunit_get_store_class());
     $this->assertEquals('cachestore_dummy', $caches['disabletest2']->phpunit_get_store_class());
     $this->assertEquals('cachestore_dummy', $caches['disabletest3']->phpunit_get_store_class());
     foreach ($caches as $cache) {
         $this->assertFalse($cache->get('test'));
         $this->assertTrue($cache->set('test', 'test'));
         $this->assertEquals('test', $cache->get('test'));
     }
 }
开发者ID:barrysspace,项目名称:moodle,代码行数:35,代码来源:cache_test.php

示例3: upgrade_noncore

/**
 * Upgrade/install other parts of moodle
 * @param bool $verbose
 * @return void, may throw exception
 */
function upgrade_noncore($verbose) {
    global $CFG;

    raise_memory_limit(MEMORY_EXTRA);

    // upgrade all plugins types
    try {
        // Disable the use of cache stores here.
        // We don't reset this, the site can live without proper caching for life of this request.
        cache_factory::disable_stores();

        $plugintypes = get_plugin_types();
        foreach ($plugintypes as $type=>$location) {
            upgrade_plugins($type, 'print_upgrade_part_start', 'print_upgrade_part_end', $verbose);
        }
        // Update cache definitions. Involves scanning each plugin for any changes.
        cache_helper::update_definitions();
    } catch (Exception $ex) {
        upgrade_handle_exception($ex);
    }
}
开发者ID:Burick,项目名称:moodle,代码行数:26,代码来源:upgradelib.php

示例4: get_config

/**
 * Get configuration values from the global config table
 * or the config_plugins table.
 *
 * If called with one parameter, it will load all the config
 * variables for one plugin, and return them as an object.
 *
 * If called with 2 parameters it will return a string single
 * value or false if the value is not found.
 *
 * @static $siteidentifier The site identifier is not cached. We use this static cache so
 *     that we need only fetch it once per request.
 * @param string $plugin full component name
 * @param string $name default NULL
 * @return mixed hash-like object or single value, return false no config found
 */
function get_config($plugin, $name = NULL)
{
    global $CFG, $DB;
    static $siteidentifier = null;
    if ($plugin === 'moodle' || $plugin === 'core' || empty($plugin)) {
        $forced =& $CFG->config_php_settings;
        $iscore = true;
        $plugin = 'core';
    } else {
        if (array_key_exists($plugin, $CFG->forced_plugin_settings)) {
            $forced =& $CFG->forced_plugin_settings[$plugin];
        } else {
            $forced = array();
        }
        $iscore = false;
    }
    if ($siteidentifier === null) {
        try {
            // This may fail during installation.
            // If you have a look at {@link initialise_cfg()} you will see that this is how we detect the need to
            // install the database.
            $siteidentifier = $DB->get_field('config', 'value', array('name' => 'siteidentifier'));
        } catch (dml_exception $ex) {
            // It's failed. We'll use this opportunity to disable cache stores so that we don't inadvertingly start using
            // old caches. People should delete their moodledata dirs when reinstalling the database... but they don't.
            cache_factory::disable_stores();
            // Set siteidentifier to false. We don't want to trip this continually.
            $siteidentifier = false;
            throw $ex;
        }
    }
    if (!empty($name)) {
        if (array_key_exists($name, $forced)) {
            return (string) $forced[$name];
        } else {
            if ($name === 'siteidentifier' && $plugin == 'core') {
                return $siteidentifier;
            }
        }
    }
    $cache = cache::make('core', 'config');
    $result = $cache->get($plugin);
    if (!$result) {
        // the user is after a recordset
        $result = new stdClass();
        if (!$iscore) {
            $result = $DB->get_records_menu('config_plugins', array('plugin' => $plugin), '', 'name,value');
        } else {
            // this part is not really used any more, but anyway...
            $result = $DB->get_records_menu('config', array(), '', 'name,value');
        }
        $cache->set($plugin, $result);
    }
    if (!empty($name)) {
        if (array_key_exists($name, $result)) {
            return $result[$name];
        }
        return false;
    }
    if ($plugin === 'core') {
        $result['siteidentifier'] = $siteidentifier;
    }
    foreach ($forced as $key => $value) {
        if (is_null($value) or is_array($value) or is_object($value)) {
            // we do not want any extra mess here, just real settings that could be saved in db
            unset($result[$key]);
        } else {
            //convert to string as if it went through the DB
            $result[$key] = (string) $value;
        }
    }
    return (object) $result;
}
开发者ID:Burick,项目名称:moodle,代码行数:89,代码来源:moodlelib.php

示例5: upgrade_noncore

/**
 * Upgrade/install other parts of moodle
 * @param bool $verbose
 * @return void, may throw exception
 */
function upgrade_noncore($verbose)
{
    global $CFG;
    raise_memory_limit(MEMORY_EXTRA);
    // upgrade all plugins types
    try {
        // Disable the use of cache stores here. We will reset the factory after we've performed the installation.
        // This ensures that we don't permanently cache anything during installation.
        cache_factory::disable_stores();
        $plugintypes = get_plugin_types();
        foreach ($plugintypes as $type => $location) {
            upgrade_plugins($type, 'print_upgrade_part_start', 'print_upgrade_part_end', $verbose);
        }
        // Update cache definitions. Involves scanning each plugin for any changes.
        cache_helper::update_definitions();
        // Reset the cache system to a normal state.
        cache_factory::reset();
    } catch (Exception $ex) {
        upgrade_handle_exception($ex);
    }
}
开发者ID:vinoth4891,项目名称:clinique,代码行数:26,代码来源:upgradelib.php


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