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


PHP navigation_cache类代码示例

本文整理汇总了PHP中navigation_cache的典型用法代码示例。如果您正苦于以下问题:PHP navigation_cache类的具体用法?PHP navigation_cache怎么用?PHP navigation_cache使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: volatile

 /**
  * Marks the cache as being volatile (likely to change)
  *
  * Any caches marked as volatile will be destroyed at the on shutdown by
  * {@link navigation_node::destroy_volatile_caches()} which is registered
  * as a shutdown function if any caches are marked as volatile.
  *
  * @param bool $setting True to destroy the cache false not too
  */
 public function volatile($setting = true)
 {
     if (self::$volatilecaches === null) {
         self::$volatilecaches = array();
         register_shutdown_function(array('navigation_cache', 'destroy_volatile_caches'));
     }
     if ($setting) {
         self::$volatilecaches[$this->area] = $this->area;
     } else {
         if (array_key_exists($this->area, self::$volatilecaches)) {
             unset(self::$volatilecaches[$this->area]);
         }
     }
 }
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:23,代码来源:navigationlib.php

示例2: rebuild_course_cache

/**
 * Rebuilds or resets the cached list of course activities stored in MUC.
 *
 * rebuild_course_cache() must NEVER be called from lib/db/upgrade.php.
 * At the same time course cache may ONLY be cleared using this function in
 * upgrade scripts of plugins.
 *
 * During the bulk operations if it is necessary to reset cache of multiple
 * courses it is enough to call {@link increment_revision_number()} for the
 * table 'course' and field 'cacherev' specifying affected courses in select.
 *
 * Cached course information is stored in MUC core/coursemodinfo and is
 * validated with the DB field {course}.cacherev
 *
 * @global moodle_database $DB
 * @param int $courseid id of course to rebuild, empty means all
 * @param boolean $clearonly only clear the cache, gets rebuild automatically on the fly.
 *     Recommended to set to true to avoid unnecessary multiple rebuilding.
 */
function rebuild_course_cache($courseid=0, $clearonly=false) {
    global $COURSE, $SITE, $DB, $CFG;

    // Function rebuild_course_cache() can not be called during upgrade unless it's clear only.
    if (!$clearonly && !upgrade_ensure_not_running(true)) {
        $clearonly = true;
    }

    // Destroy navigation caches
    navigation_cache::destroy_volatile_caches();

    if (class_exists('format_base')) {
        // if file containing class is not loaded, there is no cache there anyway
        format_base::reset_course_cache($courseid);
    }

    $cachecoursemodinfo = cache::make('core', 'coursemodinfo');
    if (empty($courseid)) {
        // Clearing caches for all courses.
        increment_revision_number('course', 'cacherev', '');
        $cachecoursemodinfo->purge();
        course_modinfo::clear_instance_cache();
        // Update global values too.
        $sitecacherev = $DB->get_field('course', 'cacherev', array('id' => SITEID));
        $SITE->cachrev = $sitecacherev;
        if ($COURSE->id == SITEID) {
            $COURSE->cacherev = $sitecacherev;
        } else {
            $COURSE->cacherev = $DB->get_field('course', 'cacherev', array('id' => $COURSE->id));
        }
    } else {
        // Clearing cache for one course, make sure it is deleted from user request cache as well.
        increment_revision_number('course', 'cacherev', 'id = :id', array('id' => $courseid));
        $cachecoursemodinfo->delete($courseid);
        course_modinfo::clear_instance_cache($courseid);
        // Update global values too.
        if ($courseid == $COURSE->id || $courseid == $SITE->id) {
            $cacherev = $DB->get_field('course', 'cacherev', array('id' => $courseid));
            if ($courseid == $COURSE->id) {
                $COURSE->cacherev = $cacherev;
            }
            if ($courseid == $SITE->id) {
                $SITE->cachrev = $cacherev;
            }
        }
    }

    if ($clearonly) {
        return;
    }

    if ($courseid) {
        $select = array('id'=>$courseid);
    } else {
        $select = array();
        core_php_time_limit::raise();  // this could take a while!   MDL-10954
    }

    $rs = $DB->get_recordset("course", $select,'','id,'.join(',', course_modinfo::$cachedfields));
    // Rebuild cache for each course.
    foreach ($rs as $course) {
        course_modinfo::build_course_cache($course);
    }
    $rs->close();
}
开发者ID:rwijaya,项目名称:moodle,代码行数:84,代码来源:modinfolib.php

示例3: rebuild_course_cache

/**
 * Rebuilds the cached list of course activities stored in the database
 * @param int $courseid - id of course to rebuild, empty means all
 * @param boolean $clearonly - only clear the modinfo fields, gets rebuild automatically on the fly
 */
function rebuild_course_cache($courseid = 0, $clearonly = false)
{
    global $COURSE, $DB, $CFG;
    // Destroy navigation caches
    navigation_cache::destroy_volatile_caches();
    if ($clearonly) {
        if (empty($courseid)) {
            $courseselect = array();
        } else {
            $courseselect = array('id' => $courseid);
        }
        $DB->set_field('course', 'modinfo', null, $courseselect);
        // update cached global COURSE too ;-)
        if ($courseid == $COURSE->id or empty($courseid)) {
            $COURSE->modinfo = null;
        }
        // reset the fast modinfo cache
        $reset = 'reset';
        get_fast_modinfo($reset);
        return;
    }
    require_once "{$CFG->dirroot}/course/lib.php";
    if ($courseid) {
        $select = array('id' => $courseid);
    } else {
        $select = array();
        @set_time_limit(0);
        // this could take a while!   MDL-10954
    }
    $rs = $DB->get_recordset("course", $select, '', 'id,fullname');
    foreach ($rs as $course) {
        $modinfo = serialize(get_array_of_activities($course->id));
        $DB->set_field("course", "modinfo", $modinfo, array("id" => $course->id));
        // update cached global COURSE too ;-)
        if ($course->id == $COURSE->id) {
            $COURSE->modinfo = $modinfo;
        }
    }
    $rs->close();
    // reset the fast modinfo cache
    $reset = 'reset';
    get_fast_modinfo($reset);
}
开发者ID:nigeldaley,项目名称:moodle,代码行数:48,代码来源:modinfolib.php

示例4: test_cache_set

 public function test_cache_set()
 {
     $cache = new navigation_cache('unittest_nav');
     $cache->anysetvariable = true;
     $cache->set('software', 'Moodle');
     $this->assertTrue($cache->cached('software'));
     $this->assertEquals($cache->software, 'Moodle');
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:8,代码来源:navigationlib_test.php

示例5: rebuild_course_cache

/**
 * Rebuilds the cached list of course activities stored in the database
 * @param int $courseid - id of course to rebuild, empty means all
 * @param boolean $clearonly - only clear the modinfo fields, gets rebuild automatically on the fly
 */
function rebuild_course_cache($courseid = 0, $clearonly = false)
{
    global $COURSE, $SITE, $DB, $CFG;
    // Destroy navigation caches
    navigation_cache::destroy_volatile_caches();
    if (class_exists('format_base')) {
        // if file containing class is not loaded, there is no cache there anyway
        format_base::reset_course_cache($courseid);
    }
    if ($clearonly) {
        if (empty($courseid)) {
            $DB->set_field('course', 'modinfo', null);
            $DB->set_field('course', 'sectioncache', null);
        } else {
            // Clear both fields in one update
            $resetobj = (object) array('id' => $courseid, 'modinfo' => null, 'sectioncache' => null);
            $DB->update_record('course', $resetobj);
        }
        // update cached global COURSE too ;-)
        if ($courseid == $COURSE->id or empty($courseid)) {
            $COURSE->modinfo = null;
            $COURSE->sectioncache = null;
        }
        if ($courseid == $SITE->id) {
            $SITE->modinfo = null;
            $SITE->sectioncache = null;
        }
        // reset the fast modinfo cache
        get_fast_modinfo($courseid, 0, true);
        return;
    }
    require_once "{$CFG->dirroot}/course/lib.php";
    if ($courseid) {
        $select = array('id' => $courseid);
    } else {
        $select = array();
        @set_time_limit(0);
        // this could take a while!   MDL-10954
    }
    $rs = $DB->get_recordset("course", $select, '', 'id,fullname');
    foreach ($rs as $course) {
        $modinfo = serialize(get_array_of_activities($course->id));
        $sectioncache = serialize(course_modinfo::build_section_cache($course->id));
        $updateobj = (object) array('id' => $course->id, 'modinfo' => $modinfo, 'sectioncache' => $sectioncache);
        $DB->update_record("course", $updateobj);
        // update cached global COURSE too ;-)
        if ($course->id == $COURSE->id) {
            $COURSE->modinfo = $modinfo;
            $COURSE->sectioncache = $sectioncache;
        }
        if ($course->id == $SITE->id) {
            $SITE->modinfo = $modinfo;
            $SITE->sectioncache = $sectioncache;
        }
    }
    $rs->close();
    // reset the fast modinfo cache
    get_fast_modinfo($courseid, 0, true);
}
开发者ID:vinoth4891,项目名称:clinique,代码行数:64,代码来源:modinfolib.php

示例6: rebuild_course_cache

/**
 * Rebuilds the cached list of course activities stored in the database
 * @param int $courseid - id of course to rebuild, empty means all
 * @param boolean $clearonly - only clear the modinfo fields, gets rebuild automatically on the fly
 */
function rebuild_course_cache($courseid=0, $clearonly=false) {
    global $COURSE, $DB, $CFG;

    if (!$clearonly && !empty($CFG->upgraderunning)) {
        debugging('Function rebuild_course_cache() should not be called from upgrade script unless with argument clearonly.',
                DEBUG_DEVELOPER);
        $clearonly = true;
    }

    // Destroy navigation caches
    navigation_cache::destroy_volatile_caches();

    if ($clearonly) {
        if (empty($courseid)) {
            $DB->set_field('course', 'modinfo', null);
            $DB->set_field('course', 'sectioncache', null);
        } else {
            // Clear both fields in one update
            $resetobj = (object)array('id' => $courseid, 'modinfo' => null, 'sectioncache' => null);
            $DB->update_record('course', $resetobj);
        }
        // update cached global COURSE too ;-)
        if ($courseid == $COURSE->id or empty($courseid)) {
            $COURSE->modinfo = null;
            $COURSE->sectioncache = null;
        }
        // reset the fast modinfo cache
        $reset = 'reset';
        get_fast_modinfo($reset);
        return;
    }

    require_once("$CFG->dirroot/course/lib.php");

    if ($courseid) {
        $select = array('id'=>$courseid);
    } else {
        $select = array();
        @set_time_limit(0);  // this could take a while!   MDL-10954
    }

    $rs = $DB->get_recordset("course", $select,'','id,fullname');
    foreach ($rs as $course) {
        $modinfo = serialize(get_array_of_activities($course->id));
        $sectioncache = serialize(course_modinfo::build_section_cache($course->id));
        $updateobj = (object)array('id' => $course->id,
                'modinfo' => $modinfo, 'sectioncache' => $sectioncache);
        $DB->update_record("course", $updateobj);
        // update cached global COURSE too ;-)
        if ($course->id == $COURSE->id) {
            $COURSE->modinfo = $modinfo;
            $COURSE->sectioncache = $sectioncache;
        }
    }
    $rs->close();
    // reset the fast modinfo cache
    $reset = 'reset';
    get_fast_modinfo($reset);
}
开发者ID:ncsu-delta,项目名称:moodle,代码行数:64,代码来源:modinfolib.php


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