當前位置: 首頁>>代碼示例>>PHP>>正文


PHP UserCache::setAllUserCache方法代碼示例

本文整理匯總了PHP中UserCache::setAllUserCache方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserCache::setAllUserCache方法的具體用法?PHP UserCache::setAllUserCache怎麽用?PHP UserCache::setAllUserCache使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UserCache的用法示例。


在下文中一共展示了UserCache::setAllUserCache方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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;
 }
開發者ID:YYLP,項目名稱:y_game,代碼行數:62,代碼來源:RankAction.class.php

示例2: iniUserInfo

 /**
  * API:初始化用戶數據
  *
  * @access public
  * @param 無
  * @return JsonView 響應json
  */
 public function iniUserInfo($user_id)
 {
     $userInfo = UserModel::getUserInfo($user_id);
     $userInfo['s_checkpoint_info'] = unserialize($userInfo['s_checkpoint_info']);
     $userInfo['s_role_info'] = unserialize($userInfo['s_role_info']);
     $userInfo['s_general_info'] = unserialize($userInfo['s_general_info']);
     $userInfo['s_item_info'] = unserialize($userInfo['s_item_info']);
     $userInfo['s_task_info'] = unserialize($userInfo['s_task_info']);
     $userInfo['s_achievement_info'] = unserialize($userInfo['s_achievement_info']);
     $userInfo['s_login_info'] = unserialize($userInfo['s_login_info']);
     UserCache::setAllUserCache($user_id, $userInfo);
     return $userInfo;
 }
開發者ID:YYLP,項目名稱:y_game,代碼行數:20,代碼來源:UserAction.class.php


注:本文中的UserCache::setAllUserCache方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。