first commit

This commit is contained in:
2026-09-11 01:41:52 +08:00
commit 9f22e6ccae
263 changed files with 28935 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
package redisdao
import (
"context"
"fmt"
"time"
"git.lzcwy.cn/zhengchiliu/zt-closet-backend/global"
"git.lzcwy.cn/zhengchiliu/zt-closet-backend/internal/redismodel"
)
// viewCountTTL 访问计数 key 的过期时间,避免长期驻留导致内存无界增长。
const viewCountTTL = 7 * 24 * time.Hour
// ClosetShareViewIncr 衣柜分享访问计数 +1,返回最新值
func ClosetShareViewIncr(ctx context.Context, shareUUID string) (int64, error) {
ctx, span := global.Tracer.Start(ctx, "redisdao.ClosetShareViewIncr")
defer span.End()
key := fmt.Sprintf(redismodel.KeyClosetShareView, shareUUID)
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
}