24 lines
641 B
Go
24 lines
641 B
Go
package redisdao
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"git.lzcwy.cn/zhengchiliu/zt-closet-backend/global"
|
|
"git.lzcwy.cn/zhengchiliu/zt-closet-backend/internal/redismodel"
|
|
)
|
|
|
|
// OutfitViewIncr 公开穿搭浏览计数 +1,返回最新值
|
|
func OutfitViewIncr(ctx context.Context, outfitID int64) (int64, error) {
|
|
ctx, span := global.Tracer.Start(ctx, "redisdao.OutfitViewIncr")
|
|
defer span.End()
|
|
|
|
key := fmt.Sprintf(redismodel.KeyOutfitView, outfitID)
|
|
val, err := quotaDailyIncrScript.Run(ctx, global.RedisEngine, []string{key}, int(viewCountTTL.Seconds())).Int64()
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
return 0, err
|
|
}
|
|
return val, nil
|
|
}
|