public function __construct($id,$time,$content,$postId) {
$this->uid = $id;
$this->timeStamp = $time;
$this->content = $content;
$this->postId = $postId;
}
public function setOriginPostId($postId)
{
$this->originPostId = $postId;
}
public function getPostId()
{
return $this->postId;
}
public function getTimeStamp()
{
return $this->timeStemp;
}
public function getUid()
{
return $this->uid;
}
public function getContent()
{
return $this->content;
}
public function getWebTitle()
{
return $this->webTitle;
}
public function pushPostId($postId)
{
$this->subPosts[] = $postId;
}
public function saveToDb()
{
$redisCli = new Redis(ServerConfig::$redisAddr);
$redisCli->hSet("post:$this->postId","uid",$this->uid);
$redisCli->hSet("post:$this->postId","time",$this->timeStamp);
$redisCli->hSet("post:$this->postId","content",$this->content);
$redisCli->hSet("post:$this->postId","originPostId",$this->originPostId);
$redisCli->set("post:$this->webTitle:$this->postId",$this->postId);
foreach($this->tags as $tag)
{
$redisCli->sAdd("post:$this->postId:tags",$tag);
}
foreach($this->subPosts as $postId)
{
$redisCli->lPush("post:$this->postId:subPost",$postId);
}