优化代码

This commit is contained in:
GoEdgeLab
2023-07-19 18:49:23 +08:00
parent 60dcd1d7c1
commit 208b713147

View File

@@ -71,7 +71,7 @@ func (this *SysLockerDAO) Lock(tx *dbs.Tx, key string, timeout int64) (ok bool,
} }
// 如果已经有锁 // 如果已经有锁
locker := one.(*SysLocker) var locker = one.(*SysLocker)
if time.Now().Unix() <= int64(locker.TimeoutAt) { if time.Now().Unix() <= int64(locker.TimeoutAt) {
return false, nil return false, nil
} }
@@ -102,7 +102,7 @@ func (this *SysLockerDAO) Lock(tx *dbs.Tx, key string, timeout int64) (ok bool,
} }
continue continue
} }
if types.Int64(version) != int64(locker.Version)+1 { if types.Int64(version) > int64(locker.Version)+1 {
return false, nil return false, nil
} }