flushing redis
This commit is contained in:
@@ -38,6 +38,7 @@ public sealed class NetworkManager
|
|||||||
_maxConnections = int.TryParse(Environment.GetEnvironmentVariable("MAX_CONN"), out var mc) ? Math.Max(mc, 100) : 10_000;
|
_maxConnections = int.TryParse(Environment.GetEnvironmentVariable("MAX_CONN"), out var mc) ? Math.Max(mc, 100) : 10_000;
|
||||||
|
|
||||||
_log.LogInformation("Tick={Hz}Hz IdleTimeout={Idle}s MaxConn={Max}", tickHz, _idleTimeout.TotalSeconds, _maxConnections);
|
_log.LogInformation("Tick={Hz}Hz IdleTimeout={Idle}s MaxConn={Max}", tickHz, _idleTimeout.TotalSeconds, _maxConnections);
|
||||||
|
redis.FlushDatabaseAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task AcceptWebSocketAsync(HttpContext ctx, WebSocket ws)
|
public async Task AcceptWebSocketAsync(HttpContext ctx, WebSocket ws)
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ public interface IRedisManager : IAsyncDisposable
|
|||||||
Task<long> StreamAddAsync(string stream, string json, string? id = "*");
|
Task<long> StreamAddAsync(string stream, string json, string? id = "*");
|
||||||
Task<RedisValue[]> StreamReadGroupAsync(string stream, string group, string consumer, int count = 100, int blockMs = 0);
|
Task<RedisValue[]> StreamReadGroupAsync(string stream, string group, string consumer, int count = 100, int blockMs = 0);
|
||||||
Task AcknowledgeAsync(string stream, string group, params string[] ids);
|
Task AcknowledgeAsync(string stream, string group, params string[] ids);
|
||||||
|
Task FlushDatabaseAsync();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class RedisManager : IRedisManager
|
public sealed class RedisManager : IRedisManager
|
||||||
@@ -175,4 +177,27 @@ public sealed class RedisManager : IRedisManager
|
|||||||
if (!string.IsNullOrWhiteSpace(password)) cs += $",password={password}";
|
if (!string.IsNullOrWhiteSpace(password)) cs += $",password={password}";
|
||||||
return cs;
|
return cs;
|
||||||
}
|
}
|
||||||
|
public async Task FlushDatabaseAsync()
|
||||||
|
{
|
||||||
|
// Redis flush commands are server-level, not IDatabase-level
|
||||||
|
var endpoints = _mux.GetEndPoints();
|
||||||
|
|
||||||
|
foreach (var endpoint in endpoints)
|
||||||
|
{
|
||||||
|
var server = _mux.GetServer(endpoint);
|
||||||
|
|
||||||
|
if (!server.IsConnected)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (server.IsReplica)
|
||||||
|
{
|
||||||
|
_logger.LogDebug("Skipping replica endpoint {Endpoint}", endpoint);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogWarning("FLUSHDB issued on Redis endpoint {Endpoint}", endpoint);
|
||||||
|
await server.FlushDatabaseAsync(Db.Database);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user