"findSet" => $findSet, //要查询的集合 "fofaSet" => $fofaSet, //互粉的集合 "findInterFollowSet" => $findInterFollowSet, //要查询的集合与我的关注交 "findInterFansSet" => $findInterFansSet //要查询的集的与我的粉丝交
/*
* userID:当前用户id
* targetUserID: 被查看的人的id
* findType: 查看的是哪个列表
* findStart: 分页查看的列表开始的位置
* findEnd: 分页查看的列表结束的位置
*/
function getChunkSets($redis, $userID, $targetUserID, $findType, $findStart, $findEnd) {
$fansKey = "fans:" . $userID;
$followKey = "follow:" . $userID;
$findKey = "find:" . $userID;
$targetKey = $findType. ":" . $targetUserID;
$fofaKey = "find_inter_fofa:" . $userID;
$findInterFollowKey = "find_inter_follow:" . $userID;
$findInterFansKey = "find_inter_fans:" . $userID;
//找出要查询的集合元素
$findSet = $redis->zRevRange($targetKey, $findStart, $findEnd, TRUE);
//要查询的集合与我的关注交
$findInterFollowSet = array();
//要查询的集的与我的粉丝交
$findInterFansSet = array();
//先清掉临时集合
$redis->del($findKey);
$redis->del($fofaKey);
$redis->del($findInterFollowKey);
$redis->del($findInterFansKey);
//存起来
foreach ($findSet as $uid => $score) {
$redis->zAdd($findKey, $score, $uid);
}
//求互粉集合
if ($userID != $targetUserID) { //看别人
$redis->zInter($fofaKey, array($findKey, $fansKey, $followKey));
/*
* 如果不是看自己的列表,还要求
* 1: 要查询的集合与我的关注交
* 2: 要查询的集的与我的粉丝交
*/
$redis->zInter($findInterFollowKey, array($findKey, $followKey));
$redis->zInter($findInterFansKey, array($findKey, $fansKey));
$findInterFollowSet = $redis->zRevRange($findInterFollowKey, 0, -1);
$findInterFansSet = $redis->zRevRange($findInterFansKey, 0, -1);
} else {
if ($findType == "fans") { //自己看粉丝列表
$redis->zInter($fofaKey, array($findKey, $followKey));
} else if ($findType == "follow") { //看自己关注列表
$redis->zInter($fofaKey, array($findKey, $fansKey));
}
}
//互粉集合
$fofaSet = $redis->zRevRange($fofaKey, 0, -1);
return array(
"findSet" => $findSet, //要查询的集合
"fofaSet" => $fofaSet, //互粉的集合
"findInterFollowSet" => $findInterFollowSet, //要查询的集合与我的关注交
"findInterFansSet" => $findInterFansSet //要查询的集的与我的粉丝交
);
}
/*
* isSelf: 是否查看自己的列表
* findType: 查看的是粉丝还是关注列表 1: 关注, 2: 粉丝
* userInfoArr: 用户详细信息数组
*/
function getUserInfoList($isSelf, $findType, $userInfoArr, $findSet, $fofaSet, $interFansSet, $interFollowSet) {
$userInfoList = array();
foreach($findSet as $userID => $favoTime) {
if(!in_array($userID, array_keys($userInfoArr))) continue;
$userInfo = new UserInfo($userInfoArr[$userID]);
$userInfo = $userInfo->format();
if(in_array($userID, $fofaSet)){
$userInfo['favoFlag'] = 3; //互相关注
} else {
if($isSelf) {
$userInfo['favoFlag'] = $findType;
} else {
if(in_array($userID, $interFansSet)) {
$userInfo['favoFlag'] = 2; //我的粉丝
} else if(in_array($userID, $interFollowSet)) {
$userInfo['favoFlag'] = 1; //我的关注
} else{
$userInfo['favoFlag'] = 0; //无关系
}
}
}
$userInfo['favoTime'] = $favoTime;
array_push($userInfoList, $userInfo);
}
return $userInfoList;
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有