public async Task GameUserLoginAsync(string gameAppId, string gameUserId, DateTimeOffset?dateTime) { int[] timePrecisions = new int[] { 3600, 3600 * 24 }; // 查找用户是否存在 if (!await GameUserExistsAsync(gameAppId, gameUserId)) { // 添加新用户 string sequentialKey = RedisKeys.Concat(gameAppId, RedisKeys.UserSequentialId); var gameUserSequentialId = await redisProvider.GetGameUserSequentialIdAsync(sequentialKey); await AddGameUserSetAsync(gameAppId, gameUserId).ConfigureAwait(false); await AddGameUserHashAsync(gameAppId, gameUserId, gameUserSequentialId).ConfigureAwait(false); // 统计新增用户 string newUserKey = RedisKeys.Concat(gameAppId, RedisKeys.NewGameUserCount); foreach (var precision in timePrecisions) { await redisProvider.UpdateCounterAsync(newUserKey, precision).ConfigureAwait(false); await redisProvider.UpdateCounterPrecisionAsync(newUserKey, precision).ConfigureAwait(false); } } // 统计用户登录 string loginKey = RedisKeys.Concat(gameAppId, RedisKeys.GameUserLoginCount); foreach (var precision in timePrecisions) { await redisProvider.UpdateCounterAsync(loginKey, precision).ConfigureAwait(false); await redisProvider.UpdateCounterPrecisionAsync(loginKey, precision).ConfigureAwait(false); } // 统计用户活跃 await GameUserActiveAsync(gameAppId, gameUserId, dateTime).ConfigureAwait(false); }