Initial commit: web_hghl_server
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
package configser
|
||||
|
||||
import (
|
||||
"context"
|
||||
"videoweb/app/api/proto"
|
||||
"videoweb/pub/common/log"
|
||||
"videoweb/pub/common/netutil"
|
||||
"videoweb/pub/models/videocreatermod"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
)
|
||||
|
||||
func updateCreateCache(ctx context.Context) {
|
||||
// 更新作者相关缓存
|
||||
createList, err := videocreatermod.FindManyVideoCreaterInfos(ctx, bson.M{
|
||||
videocreatermod.FN.VideoCreaterInfo.Status: true,
|
||||
}, options.Find().SetLimit(200).SetSort(bson.M{videocreatermod.FN.VideoCreaterInfo.Sort: -1}))
|
||||
if err != nil {
|
||||
log.Warn("updateCreateCache FindManyVideoCreaterIinfos", log.E(err))
|
||||
return
|
||||
}
|
||||
tempCreateMaps := make(map[int64]*videocreatermod.VideoCreaterInfo)
|
||||
for _, createInfo := range createList {
|
||||
tempCreateMaps[createInfo.Id] = createInfo
|
||||
}
|
||||
CacheMgr.Lock.Lock()
|
||||
CacheMgr.CreateInfo = tempCreateMaps
|
||||
CacheMgr.Lock.Unlock()
|
||||
}
|
||||
|
||||
func GetCreateInfo(createId int64, imageCdn string) proto.PostCreateInfo {
|
||||
if createId <= 0 {
|
||||
return proto.PostCreateInfo{}
|
||||
}
|
||||
CacheMgr.Lock.RLock()
|
||||
defer CacheMgr.Lock.RUnlock()
|
||||
v, ok := CacheMgr.CreateInfo[createId]
|
||||
if !ok {
|
||||
return proto.PostCreateInfo{}
|
||||
}
|
||||
return proto.PostCreateInfo{
|
||||
Id: v.Id,
|
||||
Name: v.Name,
|
||||
Slug: v.Slug,
|
||||
Image: netutil.MergeURL(imageCdn, v.Image),
|
||||
Works: v.Works,
|
||||
CreateType: v.CreateType,
|
||||
Desc: v.Desc,
|
||||
Background: v.Background,
|
||||
CreatedAt: v.CreatedAt,
|
||||
SeoInfo: v.SeoInfo,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user