28 lines
650 B
Go
28 lines
650 B
Go
package shortvideo
|
|
|
|
import (
|
|
"91porn-server/common/constant/redisconst"
|
|
"91porn-server/common/log"
|
|
"91porn-server/common/redis"
|
|
"91porn-server/models/v/vidmod"
|
|
)
|
|
|
|
// SyncDataToRedis 同步数据到redis
|
|
func SyncDataToRedis(data []*vidmod.VideoModel) error {
|
|
if len(data) == 0 {
|
|
return nil
|
|
}
|
|
|
|
for _, v := range data {
|
|
if v.NewsType != vidmod.SHORT || (v.Status != vidmod.CheckPass && v.Status != vidmod.Free) {
|
|
// 去除
|
|
_, _ = redis.Handler.SRem(redisconst.ShortVideosKey, v.ID.Hex())
|
|
} else {
|
|
_, _ = redis.Handler.SAdd(redisconst.ShortVideosKey, v.ID.Hex())
|
|
}
|
|
}
|
|
|
|
log.Info("Redis sync video data completed.")
|
|
return nil
|
|
}
|