예제 #1
0
파일: member.php 프로젝트: hamily/sblack
 /**
  * 获取多个用户的资料
  *
  * @param {array} $mids 用户游戏ID列表
  *
  * @return array
  */
 public function getAllByIds($mids)
 {
     if (!is_array($mids)) {
         return array();
     }
     $mids = array_unique($mids);
     $keys = $noKeys = $list = $return = array();
     foreach ($mids as $mid) {
         $noKeys[$mid] = $mid;
         //没有找到用户资料的ID
         $keys[$mid % 3][] = Core_Keys::getOneById($mid);
         //[散列][列表] = 缓存键
     }
     foreach ($keys as $hash => $keys) {
         $tmpList = Loader_Memcached::minfo($hash)->getMulti($keys);
         $tmpList = is_array($tmpList) ? $tmpList : array();
         foreach ($tmpList as $key => $user) {
             $list[$user[0]] = Values::uncombine(Values::getmb(), $user);
             unset($noKeys[$user[0]]);
             //已经找到该用户	//注释掉。 就可以去取缓存信息
         }
     }
     //沒有找到的,再找一遍
     foreach ($noKeys as $mid) {
         $list[$mid] = Member::factory()->getOneById($mid, true);
     }
     foreach ($mids as $mid) {
         empty($list[$mid]) ? '' : ($return[] = $list[$mid]);
     }
     return (array) $return;
 }
예제 #2
0
 /**
  * 
  * 读取游客缓存
  * @param {int} $ctype  客户端类型
  * @param {string} $type  缓存key值类型
  * @param {string} $GuestValue
  * @return {ArrayIterator} getGuestCache
  */
 private function getGuestCache($ctype, $strkey, $GuestValue)
 {
     if (empty($GuestValue)) {
         return array();
     }
     $aGuestSysKeys = array();
     if ($ctype == self::IOSCLIENTTYPE) {
         $aGuestSysKeys = self::$IOSGUESTKEY;
     } elseif ($ctype == self::ANDROIDCLIENTTYPE) {
         $aGuestSysKeys = self::$ANDROIDGUESTKEY;
     } else {
         return array();
     }
     $cTypeKey = self::$CACHETYPE[$strkey];
     $CacheKey = Core_keys::guestLoginMarkKey($GuestValue, $ctype, $cTypeKey);
     if ($strinfo = Loader_Redis::redisGuestMember()->get($CacheKey)) {
         $aCacheInfo = json_decode($strinfo, true);
         $aCacheInfo && ($info = Values::uncombine($aGuestSysKeys, $aCacheInfo));
     }
     return $info ? $info : array();
 }