/** * 点赞一条feed */ public function praise() { $feedid = intval(I('post.feedid', '')); \Predis\Autoloader::register(); $redis = new \Predis\Client(); if ($redis->zscore('feed:' . $feedid . ':praise', ACPopedom::getID())) { $res = $redis->zrem('feed:' . $feedid . ':praise', ACPopedom::getID()); $rs = $redis->hincrby('feed:' . $feedid, 'praise', -1); $this->ajaxReturn($res && $rs ? array('status' => true) : array('status' => false, 'message' => '由于服务器君罢工,取消点赞失败失败啦..')); } else { $rs = $redis->zadd('feed:' . $feedid . ':praise', time(), ACPopedom::getID()); $result = $redis->hincrby('feed:' . $feedid, 'praise', 1); $this->ajaxReturn($result && $rs ? array('status' => true, 'message' => '点赞成功了,么么哒') : array('status' => false, 'message' => '由于服务器君罢工,点赞失败失败啦..')); } }