| | |
| | | //设置有效期限为24小时 |
| | | SetTtl($"CreatSnKey:{formattedDate}", 24 * 60 * 60); |
| | | } |
| | | string re = "Ez" + formattedDate + sn.ToString(); |
| | | string re = "EZCoreCanYinLingShiGon" + formattedDate + sn.ToString(); |
| | | |
| | | return re; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="LockKey"></param> |
| | | /// <param name="expireSeconds"></param> |
| | | /// <param name="value"></param> |
| | | /// <returns></returns> |
| | | |
| | | public async Task<bool> TryLock(string LockKey, int expireSeconds = 600, string value = "Lock") |
| | | { |
| | | if (await RedisHelper.SetNxAsync(LockKey, value) == true) |
| | | { |
| | | if( await RedisHelper.ExpireAsync(LockKey, expireSeconds)==false) |
| | | return false; |
| | | return true; |
| | | } |
| | | else |
| | | return false; |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="LockKey"></param> |
| | | /// <returns></returns> |
| | | public async Task<bool > TryUnLock(string LockKey) |
| | | { |
| | | var b= await RedisHelper.DelAsync(LockKey); |
| | | if(b>0) |
| | | return true; |
| | | else |
| | | return false; |
| | | |
| | | } |
| | | } |
| | | } |