public static async Task <RedLock> CreateLockAsync(string key) { var redLock = new RedLock(); await redLock.LockAsync(key); return(redLock); }
static async Task _ProcessRankingReward(string leaderboardId, long time) { if (string.IsNullOrEmpty(leaderboardId)) { return; } var leaderboard = await GetInfo(leaderboardId); if (leaderboard != null) { string key = $"ranking_reward:{leaderboardId}:{leaderboard.seasonSeq}"; bool isUpdated = false; await using (var myLock = await RedLock.CreateLockAsync(key)) { var ret = (bool)await Cache.Instance.GetDatabase().StringGetAsync(key); if (ret) { return; } if (leaderboard.seasonEndTime < time) { await GiftReward(leaderboardId); isUpdated = true; } } if (isUpdated) { await Cache.Instance.GetDatabase().StringSetAsync(key, true, expired_time); } } }