|
|
|
@ -28,7 +28,9 @@ func (rl *RedisClientLock) Lock(ctx context.Context, key string, val string, ttl
|
|
|
|
|
// 获取
|
|
|
|
|
get, err := rl.operation.Get(ctx, key).Result()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return resp, errors.New(fmt.Sprintf("获取异常:%s", err.Error()))
|
|
|
|
|
if err != RedisNotFound {
|
|
|
|
|
return resp, errors.New(fmt.Sprintf("获取异常:%s", err.Error()))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if get != "" {
|
|
|
|
|
return resp, errors.New("上锁失败,已存在")
|
|
|
|
@ -58,7 +60,9 @@ func (rl *RedisClientLock) LockForever(ctx context.Context, key string, val stri
|
|
|
|
|
// 获取
|
|
|
|
|
get, err := rl.operation.Get(ctx, key).Result()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return resp, errors.New(fmt.Sprintf("获取异常:%s", err.Error()))
|
|
|
|
|
if err != RedisNotFound {
|
|
|
|
|
return resp, errors.New(fmt.Sprintf("获取异常:%s", err.Error()))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if get != "" {
|
|
|
|
|
return resp, errors.New("上锁失败,已存在")
|
|
|
|
|