/// <inheritdoc /> public Task InitializeAsync(CancellationToken cancellationToken = default) { var logger = _loggerFactory.CreateLogger(typeof(FireAndForget)); FireAndForget.SetLogger(logger); return(Task.CompletedTask); }
public void FireAndForgetTest() { FireAndForget.MainConnection = _connection; for (int i = 0; i < 200; i++) { FireAndForget.StringAppend("0", "str", i); FireAndForget.ListRightPush("0", "temp", i); } Thread.Sleep(1000); }
public async Task AllFiredActionsShouldBeExecuted(int count) { var stack = new ConcurrentStack <int>(); for (var i = 0; i < count; ++i) { var localIndex = i; FireAndForget.Run(() => stack.Push(localIndex)); } await Task.Delay(30 *count); stack.Count.ShouldBe(count); }
public async Task DeleteLobbyAsync(long lobby_id) { var lobby = await GetLobbyById(lobby_id); if (lobby == null) { return; } foreach (var t in lobby.Teams) { foreach (var p in t) { FireAndForget.KeyDelete(DatabaseName.Lobbies, "l:p:" + p); } } FireAndForget.KeyDelete(DatabaseName.Lobbies, "l:" + lobby_id); }
/// <summary> /// Get player lobby id /// </summary> /// <param name="player_id"> player id</param> /// <returns>returns 0 if not found otherwise returns lobby id</returns> public async ValueTask <Lobby> GetPlayerLobby(long player_id) { long lobby_id = 0; using (var db = await DataContext.Db.GetDatabaseAsync(DatabaseName.Lobbies)) lobby_id = Database.ToLong(await db.Value.StringGetAsync("l:p:" + player_id)); if (lobby_id == 0) { return(null); } var lobby = await GetLobbyById(lobby_id); if (lobby == null) { // delete player from deleted lobby FireAndForget.KeyDelete(DatabaseName.Lobbies, "l:p:" + player_id); } return(lobby); }
public void SetException(Exception exception) => FireAndForget.OnException(exception);
/// <summary> /// Update player in fire and forget mode /// </summary> /// <param name="player">Player to update</param> public void UpdatePlayerFAF(Player player) { FireAndForget.StringSet(DatabaseName.Players, "p:" + player.Id, MessagePackSerializer.Serialize(player)); }