This commit is contained in:
2026-09-15 23:04:13 +08:00
parent ade2453083
commit 8c2ea84939
17 changed files with 749 additions and 161 deletions
+12
View File
@@ -0,0 +1,12 @@
package redismodel
// AI 穿搭推荐异步任务。
//
// 推荐生成被拆成「提交任务 + 后台执行 + 前端轮询」:
// - 活跃位复用 KeyLockAIRecommend(lock:ai:recommend:%d),值为进行中的 task_id,
// 既做同一用户互斥,也让重复提交能拿回同一个任务而不是报「请求过于频繁」;
// - 任务快照独立存储,供前端按 task_id 轮询,生命周期不绑定 HTTP 连接。
const (
// KeyAIRecommendTask 任务快照(JSON),task_id 维度。
KeyAIRecommendTask = RedisPrefix + "ai:recommend:task:%s"
)
+1 -1
View File
@@ -5,7 +5,7 @@ const (
KeyLockOrderCreate = RedisPrefix + "lock:order:create:%d" // order_id,下单防重
KeyLockPayCallback = RedisPrefix + "lock:pay:callback:%s" // order_no,支付回调幂等
KeyLockRefundCallback = RedisPrefix + "lock:refund:callback:%s" // refund_no,退款回调幂等
KeyLockAIRecommend = RedisPrefix + "lock:ai:recommend:%d" // user_id,AI推荐防并发
KeyLockAIRecommend = RedisPrefix + "lock:ai:recommend:%d" // user_id,AI推荐活跃位:值为进行中的 task_id,兼作防并发
KeyLockAIHoroscope = RedisPrefix + "lock:ai:horoscope:%d:%s" // user_id:zodiac,AI星座防并发
KeyLockClosetAudit = RedisPrefix + "lock:audit:closet:%d" // target_id,衣柜分享审核防重
KeyLockOutfitAudit = RedisPrefix + "lock:audit:outfit:%d" // target_id,穿搭审核防重