本文整理汇总了PHP中get_cache_flag函数的典型用法代码示例。如果您正苦于以下问题:PHP get_cache_flag函数的具体用法?PHP get_cache_flag怎么用?PHP get_cache_flag使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_cache_flag函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: test_mark_user_preferences_changed
public function test_mark_user_preferences_changed()
{
$this->resetAfterTest();
$otheruser = $this->getDataGenerator()->create_user();
$otheruserid = $otheruser->id;
set_cache_flag('userpreferenceschanged', $otheruserid, null);
mark_user_preferences_changed($otheruserid);
$this->assertEquals(get_cache_flag('userpreferenceschanged', $otheruserid, time() - 10), 1);
set_cache_flag('userpreferenceschanged', $otheruserid, null);
}
开发者ID:miguelangelUvirtual,项目名称:uEducon,代码行数:10,代码来源:moodlelib_test.php
示例2: test_mark_user_preferences_changed
public function test_mark_user_preferences_changed()
{
if (!($otheruserid = $this->get_fake_preference_test_userid())) {
$this->fail('Can not find unused user id for the preferences test');
return;
}
set_cache_flag('userpreferenceschanged', $otheruserid, NULL);
mark_user_preferences_changed($otheruserid);
$this->assertEqual(get_cache_flag('userpreferenceschanged', $otheruserid, time() - 10), 1);
set_cache_flag('userpreferenceschanged', $otheruserid, NULL);
}
开发者ID:richheath,项目名称:moodle,代码行数:11,代码来源:testmoodlelib.php
示例3: check_user_preferences_loaded
/**
* Refresh user preference cache. This is used most often for $USER
* object that is stored in session, but it also helps with performance in cron script.
*
* Preferences for each user are loaded on first use on every page, then again after the timeout expires.
*
* @package core
* @category preference
* @access public
* @param stdClass $user User object. Preferences are preloaded into 'preference' property
* @param int $cachelifetime Cache life time on the current page (in seconds)
* @throws coding_exception
* @return null
*/
function check_user_preferences_loaded(stdClass $user, $cachelifetime = 120)
{
global $DB;
// Static cache, we need to check on each page load, not only every 2 minutes.
static $loadedusers = array();
if (!isset($user->id)) {
throw new coding_exception('Invalid $user parameter in check_user_preferences_loaded() call, missing id field');
}
if (empty($user->id) or isguestuser($user->id)) {
// No permanent storage for not-logged-in users and guest.
if (!isset($user->preference)) {
$user->preference = array();
}
return;
}
$timenow = time();
if (isset($loadedusers[$user->id]) and isset($user->preference) and isset($user->preference['_lastloaded'])) {
// Already loaded at least once on this page. Are we up to date?
if ($user->preference['_lastloaded'] + $cachelifetime > $timenow) {
// No need to reload - we are on the same page and we loaded prefs just a moment ago.
return;
} else {
if (!get_cache_flag('userpreferenceschanged', $user->id, $user->preference['_lastloaded'])) {
// No change since the lastcheck on this page.
$user->preference['_lastloaded'] = $timenow;
return;
}
}
}
// OK, so we have to reload all preferences.
$loadedusers[$user->id] = true;
$user->preference = $DB->get_records_menu('user_preferences', array('userid' => $user->id), '', 'name,value');
// All values.
$user->preference['_lastloaded'] = $timenow;
}
开发者ID:lucaboesch,项目名称:moodle,代码行数:49,代码来源:moodlelib.php
示例4: check_user_preferences_loaded
/**
* Refresh current $USER session global variable with all their current preferences.
*
* @global object
* @param mixed $time default null
* @return void
*/
function check_user_preferences_loaded($time = null)
{
global $USER, $DB;
static $timenow = null;
// Static cache, so we only check up-to-dateness once per request.
if (!empty($USER->preference) && isset($USER->preference['_lastloaded'])) {
// Already loaded. Are we up to date?
if (is_null($timenow) || !is_null($time) && $time != $timenow) {
$timenow = time();
if (!get_cache_flag('userpreferenceschanged', $USER->id, $USER->preference['_lastloaded'])) {
// We are up-to-date.
return;
}
} else {
// Already checked for up-to-date-ness.
return;
}
}
// OK, so we have to reload. Reset preference
$USER->preference = array();
if (!isloggedin() or isguestuser()) {
// No permanent storage for not-logged-in user and guest
} else {
if ($preferences = $DB->get_records('user_preferences', array('userid' => $USER->id))) {
foreach ($preferences as $preference) {
$USER->preference[$preference->name] = $preference->value;
}
}
}
$USER->preference['_lastloaded'] = $timenow;
}
开发者ID:ajv,项目名称:Offline-Caching,代码行数:38,代码来源:moodlelib.php
注:本文中的get_cache_flag函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论