mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 17:23:26 +08:00
优化下单redis锁
This commit is contained in:
@@ -159,7 +159,8 @@ namespace CoreCms.Net.Web.WebApi.Controllers
|
||||
var jm = new WebApiCallBack();
|
||||
|
||||
var lockKey = "LOCK_CreateOrder:user_" + _user.ID;
|
||||
var redisUserLock = await _redisOperationRepository.LockTakeAsync(lockKey, _user.ID.ToString(), TimeSpan.FromSeconds(10));
|
||||
var lockHolder = Guid.NewGuid().ToString("N"); //锁持有者
|
||||
var redisUserLock = await _redisOperationRepository.LockTakeAsync(lockKey, lockHolder, TimeSpan.FromSeconds(10));
|
||||
if (redisUserLock)
|
||||
{
|
||||
try
|
||||
@@ -226,7 +227,7 @@ namespace CoreCms.Net.Web.WebApi.Controllers
|
||||
}
|
||||
finally
|
||||
{
|
||||
await _redisOperationRepository.LockReleaseAsync(lockKey, _user.ID.ToString());
|
||||
await _redisOperationRepository.LockReleaseAsync(lockKey, lockHolder);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user