Documentation ¶
Index ¶
- type Dao
- func (d *Dao) AddCacheTopicInfo(ctx context.Context, topicInfos map[int64]*api.TopicInfo) (err error)
- func (d *Dao) AddCacheVideoExtension(ctx context.Context, extensions map[int64]*api.VideoExtension) (err error)
- func (d *Dao) CacheTopicInfo(ctx context.Context, topicIDs []int64) (res map[int64]*api.TopicInfo, err error)
- func (d *Dao) CacheVideoExtension(ctx context.Context, svids []int64) (res map[int64]*api.VideoExtension, err error)
- func (d *Dao) Close()
- func (d *Dao) DelCacheTopicInfo(ctx context.Context, topicID int64)
- func (d *Dao) DelCacheVideoExtension(ctx context.Context, svid int64)
- func (d *Dao) GetStickTopic(ctx context.Context) (list []int64, err error)
- func (d *Dao) GetStickTopicVideo(ctx context.Context, topicID int64) (list []int64, err error)
- func (d *Dao) GetVideoTopic(ctx context.Context, svid int64) (list []*api.TopicVideoItem, err error)
- func (d *Dao) InsertExtension(ctx context.Context, svid int64, extensionType int64, extension *api.Extension) (rowsAffected int64, err error)
- func (d *Dao) InsertTopicVideo(ctx context.Context, svid int64, topicIDs []int64) (rowsAffected int64, err error)
- func (d *Dao) InsertTopics(ctx context.Context, topics map[string]*api.TopicInfo) (newTopics map[string]*api.TopicInfo, err error)
- func (d *Dao) ListRankTopics(ctx context.Context, page int32, size int32) (list []int64, hasMore bool, err error)
- func (d *Dao) ListTopicVideos(ctx context.Context, topicID int64, cursorPrev, cursorNext string, size int) (res []*api.VideoItem, hasMore bool, err error)
- func (d *Dao) ListUnAvailableTopics(ctx context.Context, page int32, size int32) (list []int64, hasMore bool, err error)
- func (d *Dao) Ping(ctx context.Context) (err error)
- func (d *Dao) RawTopicInfo(ctx context.Context, topicIDs []int64) (res map[int64]*api.TopicInfo, err error)
- func (d *Dao) RawVideoExtension(ctx context.Context, svids []int64) (res map[int64]*api.VideoExtension, err error)
- func (d *Dao) SetStickTopicVideo(ctx context.Context, topicID int64, list []int64) (err error)
- func (d *Dao) StickTopic(ctx context.Context, opTopicID, op int64) (err error)
- func (d *Dao) StickTopicVideo(ctx context.Context, opTopicID, opSvid, op int64) (err error)
- func (d *Dao) TopicID(ctx context.Context, names []string) (topics map[string]int64, err error)
- func (d *Dao) TopicInfo(c context.Context, keys []int64) (res map[int64]*api.TopicInfo, err error)
- func (d *Dao) UpdateTopic(ctx context.Context, topicID int64, field string, value interface{}) (err error)
- func (d *Dao) UpdateVideoScore(ctx context.Context, svid int64, score float64) (err error)
- func (d *Dao) UpdateVideoState(ctx context.Context, svid int64, state int32) (err error)
- func (d *Dao) VideoExtension(c context.Context, keys []int64) (res map[int64]*api.VideoExtension, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dao ¶
type Dao struct {
// contains filtered or unexported fields
}
Dao dao.
func (*Dao) AddCacheTopicInfo ¶
func (d *Dao) AddCacheTopicInfo(ctx context.Context, topicInfos map[int64]*api.TopicInfo) (err error)
AddCacheTopicInfo 添加topic info缓存
func (*Dao) AddCacheVideoExtension ¶
func (d *Dao) AddCacheVideoExtension(ctx context.Context, extensions map[int64]*api.VideoExtension) (err error)
AddCacheVideoExtension 添加extension缓存
func (*Dao) CacheTopicInfo ¶
func (d *Dao) CacheTopicInfo(ctx context.Context, topicIDs []int64) (res map[int64]*api.TopicInfo, err error)
CacheTopicInfo 从缓存获取topic info
func (*Dao) CacheVideoExtension ¶
func (d *Dao) CacheVideoExtension(ctx context.Context, svids []int64) (res map[int64]*api.VideoExtension, err error)
CacheVideoExtension 从缓存获取extension
func (*Dao) DelCacheTopicInfo ¶
DelCacheTopicInfo 删除topic info缓存
func (*Dao) DelCacheVideoExtension ¶
DelCacheVideoExtension 删除extension缓存
func (*Dao) GetStickTopic ¶
GetStickTopic 获取置顶视频 TODO: 这个方式是临时之计,当qps增大时,会导致热点的产生
func (*Dao) GetStickTopicVideo ¶
GetStickTopicVideo 获取置顶视频
func (*Dao) GetVideoTopic ¶
func (d *Dao) GetVideoTopic(ctx context.Context, svid int64) (list []*api.TopicVideoItem, err error)
GetVideoTopic 获取视频的话题列表
func (*Dao) InsertExtension ¶
func (d *Dao) InsertExtension(ctx context.Context, svid int64, extensionType int64, extension *api.Extension) (rowsAffected int64, err error)
InsertExtension 插入extension到db
func (*Dao) InsertTopicVideo ¶
func (d *Dao) InsertTopicVideo(ctx context.Context, svid int64, topicIDs []int64) (rowsAffected int64, err error)
InsertTopicVideo 插入topic video表
func (*Dao) InsertTopics ¶
func (d *Dao) InsertTopics(ctx context.Context, topics map[string]*api.TopicInfo) (newTopics map[string]*api.TopicInfo, err error)
InsertTopics 插入话题
func (*Dao) ListRankTopics ¶
func (d *Dao) ListRankTopics(ctx context.Context, page int32, size int32) (list []int64, hasMore bool, err error)
ListRankTopics 获取推荐的话题列表 TODO: 把置顶逻辑移上去
func (*Dao) ListTopicVideos ¶
func (d *Dao) ListTopicVideos(ctx context.Context, topicID int64, cursorPrev, cursorNext string, size int) (res []*api.VideoItem, hasMore bool, err error)
ListTopicVideos 获取话题下排序的视频列表 按道理来说,Dao层不应该有那么多的复杂逻辑的,但是redis、db等操作在业务本身就是耦合在一起的,因此移到dao层,简化逻辑操作 TODO: 这里把置顶的数据放在了redis里,所以导致排序问题过于复杂,待修正
func (*Dao) ListUnAvailableTopics ¶
func (d *Dao) ListUnAvailableTopics(ctx context.Context, page int32, size int32) (list []int64, hasMore bool, err error)
ListUnAvailableTopics .
func (*Dao) RawTopicInfo ¶
func (d *Dao) RawTopicInfo(ctx context.Context, topicIDs []int64) (res map[int64]*api.TopicInfo, err error)
RawTopicInfo 从mysql获取topic info
func (*Dao) RawVideoExtension ¶
func (d *Dao) RawVideoExtension(ctx context.Context, svids []int64) (res map[int64]*api.VideoExtension, err error)
RawVideoExtension 从mysql获取extension
func (*Dao) SetStickTopicVideo ¶
SetStickTopicVideo 设置置顶视频
func (*Dao) StickTopic ¶
StickTopic .
func (*Dao) StickTopicVideo ¶
StickTopicVideo 操作置顶视频
func (*Dao) TopicInfo ¶
TopicInfo get data from cache if miss will call source method, then add to cache.
func (*Dao) UpdateTopic ¶
func (d *Dao) UpdateTopic(ctx context.Context, topicID int64, field string, value interface{}) (err error)
UpdateTopic 更新话题,当前有简介和状态 这个函数把操作权其实已经交给上层了,设计上不是个好设计,但是在于避免重复代码
func (*Dao) UpdateVideoScore ¶
UpdateVideoScore 更新视频的score
@param topicID: 携带的时候会修改指定的topicID的video的score,否则会全部修改
func (*Dao) UpdateVideoState ¶
UpdateVideoState 更新视频的state
func (*Dao) VideoExtension ¶
func (d *Dao) VideoExtension(c context.Context, keys []int64) (res map[int64]*api.VideoExtension, err error)
VideoExtension get data from cache if miss will call source method, then add to cache.