本文整理匯總了PHP中course_modinfo::instancecache方法的典型用法代碼示例。如果您正苦於以下問題:PHP course_modinfo::instancecache方法的具體用法?PHP course_modinfo::instancecache怎麽用?PHP course_modinfo::instancecache使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類course_modinfo
的用法示例。
在下文中一共展示了course_modinfo::instancecache方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: clear_instance_cache
/**
* Clears the cache used in course_modinfo::instance()
*
* Used in {@link get_fast_modinfo()} when called with argument $reset = true
* and in {@link rebuild_course_cache()}
*
* @param null|int|stdClass $courseorid if specified removes only cached value for this course
*/
public static function clear_instance_cache($courseorid = null) {
if (empty($courseorid)) {
self::$instancecache = array();
self::$cacheaccessed = array();
return;
}
if (is_object($courseorid)) {
$courseorid = $courseorid->id;
}
if (isset(self::$instancecache[$courseorid])) {
// Unsetting static variable in PHP is peculiar, it removes the reference,
// but data remain in memory. Prior to unsetting, the varable needs to be
// set to empty to remove its remains from memory.
self::$instancecache[$courseorid] = '';
unset(self::$instancecache[$courseorid]);
unset(self::$cacheaccessed[$courseorid]);
}
}