分布式锁避坑 - Joeyin

Wait 5 sec.

【摘要】1. 锁必须有TTL // 错误 redis.Set("lock", 1) // 永远不能释放 // 正确 redis.SetNX("lock", uuid, 5 * time.Minute) 2. 长时间任务必须续期 go refreshLock(ctx, lock, 1 * time.Minut 阅读全文