优化锁的索引绝对值获取

This commit is contained in:
xuejiaming 2022-11-27 10:18:19 +08:00
parent ce937b118c
commit bf676d6815
1 changed files with 2 additions and 1 deletions

View File

@ -60,7 +60,8 @@ namespace ShardingCore.Core.ModelCacheLockerProviders
}
var hashCode = (modelCacheKey.ToString() ?? "").GetHashCode();
var index = Math.Abs(hashCode % _locks.Count);
var lockIndex = hashCode % _locks.Count;
var index = lockIndex >= 0 ? lockIndex : Math.Abs(lockIndex);
return _locks[index];
}
}