本文整理汇总了PHP中UserCache::deleteAllUserCache方法的典型用法代码示例。如果您正苦于以下问题:PHP UserCache::deleteAllUserCache方法的具体用法?PHP UserCache::deleteAllUserCache怎么用?PHP UserCache::deleteAllUserCache使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserCache
的用法示例。
在下文中一共展示了UserCache::deleteAllUserCache方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: exeGetUserInfo
/**
* API:获取解锁关卡基本信息
*
* @access public
* @param 无
* @return JsonView 响应json
*/
public function exeGetUserInfo()
{
$requestParam = $this->getAllParameters();
Logger::debug('requestParam:' . print_r($requestParam, true));
$requestJsonParam = $this->getDecodedJsonRequest();
Logger::debug('requestJsonParam:' . print_r($requestJsonParam, true));
// 获取用户表信息
UserCache::deleteAllUserCache($requestParam['user_id']);
$userInfo = UserCache::getAllUserCache($requestParam['user_id']);
if (!$userInfo) {
$userInfo = self::iniUserInfo($requestParam['user_id']);
}
// 检测体力
$checkThewArr['n_thew'] = $userInfo['n_thew'];
$checkThewArr['n_refresh_time'] = $userInfo['n_refresh_time'];
$checkArr = self::refreshThew($checkThewArr);
if ($checkArr) {
UserModel::update($checkArr, $user = array('n_id' => $requestParam['user_id']), $pdo);
UserCache::setByKey($requestParam['user_id'], 'n_thew', $checkArr['n_thew']);
UserCache::setByKey($requestParam['user_id'], 'n_refresh_time', $checkArr['n_refresh_time']);
$userInfo['n_thew'] = $checkArr['n_thew'];
$userInfo['n_refresh_time'] = $checkArr['n_refresh_time'];
}
$nowTime = time();
// 生成缓存
$newSessionKey = Util::generateSessionKey($requestParam['user_id']);
$oldSessionKey = $requestParam['session_key'];
Logger::debug('SessionKey1:' . $oldSessionKey);
Logger::debug('SessionKey2:' . $newSessionKey);
UserCache::setByKey($requestParam['user_id'], Constants::PREVIOUS_SESSION_KEY, $oldSessionKey);
UserCache::setByKey($requestParam['user_id'], Constants::CURRENT_SESSION_KEY, $newSessionKey);
//UserCache::setByKey($user_id, 'userInfo', $userInfo);
$messageArr = CharacterAction::getAllMessage($requestParam['user_id']);
$messageArr['bullent'] = SystemAction::getBulletin();
$messageArr['big_message'] = SystemAction::getBigMessage();
$messageArr['s_login_info'] = $userInfo['s_login_info'];
$messageArr['user_info']['s_name'] = $userInfo['s_name'];
$messageArr['user_info']['n_level'] = $userInfo['n_level'];
$messageArr['user_info']['f_experience'] = $userInfo['f_experience'];
$messageArr['user_info']['n_coin'] = $userInfo['n_coin'];
$messageArr['user_info']['n_diamond'] = $userInfo['n_diamond'];
$messageArr['user_info']['n_soul'] = $userInfo['n_soul'];
//$messageArr['user_info']['n_reward'] = $userInfo['n_reward'];
$messageArr['user_info']['n_head'] = $userInfo['n_head'];
$messageArr['user_info']['n_thew'] = $userInfo['n_thew'];
$messageArr['user_info']['n_refresh_time'] = $userInfo['n_refresh_time'];
$messageArr['user_info']['server_time'] = $nowTime;
$messageArr['user_info']['time_num'] = Constants::REFRESH_THEW_TIME;
$messageArr['user_info']['n_battle'] = $userInfo['n_battle'];
//$messageArr['user_info']['s_role_info'] = $userInfo['s_role_info'];
//$messageArr['user_info']['s_general_info'] = $userInfo['s_general_info'];
$messageArr['role_id'] = $userInfo['s_role_info'][0];
$messageArr['item'] = $userInfo['s_item_info'];
$messageArr['id'] = $requestParam['user_id'];
//$messageArr = $userInfo;
$messageArr['session_key'] = $newSessionKey;
$view = new JsonView();
return $this->getViewByJson($view, $messageArr, 1, "system/get_bulletin");
}
示例2: getWorldRank
/**
* API:获取世界排行
*
* @access public
* @param 无
* @return JsonView 响应json
*/
public function getWorldRank($user_id)
{
UserCache::deleteAllUserCache(Constants::WORLD_RANK);
//$rankArr = UserCache::getAllUserCache( Constants::WORLD_RANK );
$friendList = FriendAction::getFriend($user_id);
if (!$rankArr) {
//$worldRank = rankModel::selectlimit( $wheres = "",$limit = array( "page" => 1, "limit" => Constants::WORLD_RANKY_MAX_NUM ), $columns = array( "n_id", 'n_battle', 'n_max_checkpoint' ) );
$worldRank = RankModel::getRank(Constants::WORLD_RANKY_MAX_NUM);
foreach ($worldRank as $key => $value) {
$result['max_checkpoint'] = $value['n_max_checkpoint'];
$result['battle'] = $value['n_battle'];
$result['n_id'] = $value['n_id'];
$rankArr[$value['n_id']] = $result;
}
//echo "<pre>";var_dump($worldRank);exit;
UserCache::setAllUserCache(Constants::WORLD_RANK, $rankArr);
}
// uasort($rankArr, function($a, $b) {
// $al = $a['max_checkpoint'];
// $bl = $b['max_checkpoint'];
// if ($al == $bl)
// {
// $al2 = $a['battle'];
// $bl2 = $b['battle'];
// return ($al2 > $bl2) ? -1 : 1;
// }
// return ($al > $bl) ? -1 : 1;
// });
$rankArr = array_slice($rankArr, 0, Constants::WORLD_RANKY_MAX_NUM);
//echo "<pre>";
foreach ($rankArr as $key => $value) {
$now_id = $value['n_id'];
$userInfo = UserCache::getAllUserCache($now_id);
if (!$userInfo['n_id'] || !$userInfo['n_head'] || !$userInfo['s_name'] || !$userInfo['n_sex'] || !$userInfo['n_level'] || !$userInfo['n_max_checkpoint']) {
$userInfo = UserAction::iniUserInfo($now_id);
}
//var_dump($userInfo);echo "<br />";
$rankInfo['id'] = $userInfo['n_id'];
$rankInfo['head'] = $userInfo['n_head'];
$rankInfo['name'] = $userInfo['s_name'];
$rankInfo['sex'] = $userInfo['n_sex'];
$rankInfo['level'] = $userInfo['n_level'];
$rankInfo['checkpoint'] = $userInfo['n_max_checkpoint'];
$rankInfo['battle'] = $value['battle'];
// 好友列表加入缓存后此处需要修改
//$rankInfo['friend_type'] = FriendModel::isFriend( $user_id, $now_id );
if ($friendList && in_array($now_id, $friendList)) {
$rankInfo['friend_type'] = 1;
} else {
$rankInfo['friend_type'] = 0;
}
$worldRankInfo[$key + 1] = $rankInfo;
}
return $worldRankInfo;
}