func InsertComment(comment model.Comment) (ret model.Comment, err error) { s := mongo.GetSession() defer s.Close() c := collection(s, util.MONGO_COLLECTION_COMMENT) comment.Cid = bson.NewObjectId() comment.Ctime = util.UnixMillSeconds() return comment, c.Insert(comment) }
func redisComments(key string, from int64, to int64) (rets []model.Comment, err error) { var strs []string strs, err = redisStrs(key, from, to) if err != nil { return nil, err } rets = make([]model.Comment, len(strs)) for pos, str := range strs { comment := model.Comment{} comment.Cid = bson.ObjectIdHex(str) rets[pos] = comment } return }