"10.1.3.89", "port" => "443"); public $memcache = array( 'servers' => array( array('host' => 'livestockmem.r2bd3q.cfg.cnn1.cache.amazonaws.com.cn', 'port' => 11211), ), 'prefix' => 'zjcj', 'expire' => 900, ); function __construct() { $this->socket = new CSocket($this->params); $this->cache = new CMemcache($this->memcache); } /** * @ follow 添加关注 * * @param array $param * UserID 用户编号 * Type 数据类型 0-好友用户编号,1-好友用户名,2-好友用户昵称 * FriendData 数据内容 * FType 好友类别 0-互相关注,1-黑名单,2-关注 * @access public * @return bool */ public function follow($param) { $type = 'U110'; //error_log('model' . date("Y-m-d H:i:s") . print_r($param, true), 3, '/home/httpd/logs/addblack.log'); $rs = $this->socket->senddata($type, $param); //error_log('U110xml' . date("Y-m-d H:i:s") . print_r($rs, true), 3, '/home/httpd/logs/addblack.log'); if ($rs['Status']['Code'] == '00') { $ckey = 'Friends_GetFriendsList_Count_{UserID}_{FType}'; $ckey = str_replace('{UserID}', $param['UserID'], $ckey); $ckey = str_replace('{FType}', '0', $ckey); $this->cache->delete($ckey); $ckey = 'Friends_GetFriendsList_Count_{UserID}_{FType}'; $ckey = str_replace('{UserID}', $param['UserID'], $ckey); $ckey = str_replace('{FType}', '3', $ckey); $this->cache->delete($ckey); $ckey = 'get_fans_Fllower_num_{userid}'; $ckey = str_replace('{userid}', $param['FriendData'], $ckey); $this->cache->delete($ckey); return true; } else { return false; } } //粉丝,我关注的,相互关注数 function getFriendContact($data) { $type = 'U115'; // var_dump($data); $rs = $this->socket->senddata($type, $data); if ($rs["Status"]["RetRecords"] > 0) { $rs["Records"]["Record"]["RetRecords"] = $rs["Status"]["RetRecords"]; return $rs["Records"]["Record"]; } else { $rs["Records"]["Record"]["RetRecords"] = 0; return false; } } /** * @ unfollow 取消关注 * * @param array $param * UserID 用户编号 * Type 数据类型 0-好友用户编号,1-好友用户名,2-好友用户昵称 * FriendData 数据内容 * FType 好友类别 0-删除我关注的好友,1-黑名单,2-拒绝好友关注 * @access public * @return bool */ public function unfollow($param) { $type = 'U111'; // var_dump($param); $rs = $this->socket->senddata($type, $param); if ($rs['Status']['Code'] == '00') { $param['UserID'] = isset($param['act']) ? $param['FriendData'] : $param['UserID']; $ckey = 'Friends_GetFriendsList_Count_{UserID}_{FType}'; $ckey = str_replace('{UserID}', $param['UserID'], $ckey); $ckey = str_replace('{FType}', '2', $ckey); $this->cache->delete($ckey); $ckey = 'Friends_GetFriendsList_Count_{UserID}_{FType}'; $ckey = str_replace('{UserID}', $param['UserID'], $ckey); $ckey = str_replace('{FType}', '0', $ckey); $this->cache->delete($ckey); $ckey = 'Friends_GetFriendsList_Count_{UserID}_{FType}'; $ckey = str_replace('{UserID}', $param['UserID'], $ckey); $ckey = str_replace('{FType}', '3', $ckey); $this->cache->delete($ckey); $ckey = 'get_fans_Fllower_num_{userid}'; $ckey = str_replace('{userid}', $param['FriendData'], $ckey); $this->cache->delete($ckey); return true; } else { return false; } } /** * @ verify 验证好友 * * @param array $param * UserID 用户编号 * FUserIDs 好友用户编号,多笔用逗号隔开 * @access public * @return bool */ public function verify($param) { $type = 'U107'; $rs = $this->socket->senddata($type, $param); var_dump($rs); if ($rs['Code'] == '00') { $result = array(); if ($rs['RetRecords'] == '1') { $result = array($rs['Record']); } else { $result = $rs['Record']; } /* unset($rs); foreach($result as $v) { $rs[$v['FUserID']] = $v['FriendStatus']; } */ return $result; } else { return false; } } public function delmyindex($userid) { $ckey = "Friends_GetFriendsList_Count_" . $userid . "_0"; $this->cache->delete($ckey); $ckey = "Friends_GetFriendsList_Count_" . $userid . "_0" . "_0"; $this->cache->delete($ckey); $ckey = "Friends_GetFriendsList_Count_" . $userid . "_0" . "_20"; $this->cache->delete($ckey); $ckey = "Friends_GetFriendsList_Count_" . $userid . "_2"; $this->cache->delete($ckey); $ckey = "Friends_GetFriendsList_Count_" . $userid . "_2" . "_0"; $this->cache->delete($ckey); $ckey = "Friends_GetFriendsList_Count_" . $userid . "_2" . "_20"; $this->cache->delete($ckey); } public function getFriendList($data) { $type = 'U104'; if (ISCACHE) { if ($data['StartNo'] == '-1') { if ($data["FNickName"]) { $ckey = "Friends_GetFriendsList_Count_{UserID}_{FType}_{FNickName}"; $ckey = str_replace('{FNickName}', $data['FNickName'], $ckey); } else { $ckey = "Friends_GetFriendsList_Count_{UserID}_{FType}"; } $ckey = str_replace('{UserID}', $data['UserID'], $ckey); $ckey = str_replace('{FType}', $data['FType'], $ckey); $rs = $this->cache->get($ckey); if (!$rs) { $rs = $this->socket->senddata($type, $data); if ($rs["Status"]["TtlRecords"] > 0) { $rs['FlagCode'] = md5($rs['TtlRecords'] . time()); $this->cache->set($ckey, $rs); return $rs; } else { return $rs["Status"]["TtlRecords"] = 0; } } return $rs; } else { if ($data["FNickName"]) { $ckey = "Friends_GetFriendsList_Count_{UserID}_{FType}_{PageNo}_{FNickName}_{QryCount}"; $ckey = str_replace('{FNickName}', $data['FNickName'], $ckey); $ckey = str_replace('{QryCount}', $data['QryCount'], $ckey); } else { $ckey = "Friends_GetFriendsList_Count_{UserID}_{FType}_{PageNo}_{QryCount}"; } $ckey = str_replace('{UserID}', $data['UserID'], $ckey); $ckey = str_replace('{FType}', $data['FType'], $ckey); $ckey = str_replace('{PageNo}', $data['StartNo'], $ckey); $ckey = str_replace('{QryCount}', $data['QryCount'], $ckey); $rs = $this->cache->get($ckey); //$rs = ""; //上线后改回来 if (!$rs || $rs['FlagCode'] != $data['FlagCode']) { $rs = $this->socket->senddata($type, $data); if ($rs["Status"]["RetRecords"] > 0) { $rs['FlagCode'] = $data['FlagCode']; $this->cache->set($ckey, $rs); return $rs; } else { $rs["Status"]["RetRecords"] = 0; return $rs; } } return $rs; } } else { $rs = $this->socket->senddata($type, $data); if ($data['StartNo'] == '-1') { if (!$rs) { $rs["Status"]["TtlRecords"] = 0; return $rs; } return $rs; } else { return $rs; } //return ( isset($rs['Record']) ? $rs['Record'] : false ); } } } //end class ?>