mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-05 11:28:39 +00:00
Add command to flush redis database
This commit is contained in:
parent
caa4b9bec1
commit
02abb7bcab
2 changed files with 35 additions and 2 deletions
|
@ -0,0 +1,20 @@
|
|||
using System.Threading.Tasks;
|
||||
using LBPUnion.ProjectLighthouse.Logging;
|
||||
using LBPUnion.ProjectLighthouse.StorableLists;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Administration.Maintenance.Commands;
|
||||
|
||||
public class FlushRedisCommand : ICommand
|
||||
{
|
||||
public string Name() => "Flush Redis";
|
||||
public string[] Aliases() => new[] {
|
||||
"flush", "flush-redis",
|
||||
};
|
||||
public string Arguments() => "";
|
||||
public int RequiredArgs() => 0;
|
||||
|
||||
public async Task Run(string[] args, Logger logger)
|
||||
{
|
||||
await RedisDatabase.FlushAll();
|
||||
}
|
||||
}
|
|
@ -39,8 +39,7 @@ public static class RedisDatabase
|
|||
return;
|
||||
}
|
||||
|
||||
await connection.RecreateIndexAsync(typeof(Room));
|
||||
await connection.RecreateIndexAsync(typeof(UserFriendData));
|
||||
await createIndexes(connection);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
|
@ -52,6 +51,20 @@ public static class RedisDatabase
|
|||
Logger.Success("Initialized Redis.", LogArea.Redis);
|
||||
}
|
||||
|
||||
public static async Task FlushAll()
|
||||
{
|
||||
IRedisConnection connection = getConnection();
|
||||
await connection.ExecuteAsync("FLUSHALL");
|
||||
|
||||
await createIndexes(connection);
|
||||
}
|
||||
|
||||
private static async Task createIndexes(IRedisConnection connection)
|
||||
{
|
||||
await connection.RecreateIndexAsync(typeof(Room));
|
||||
await connection.RecreateIndexAsync(typeof(UserFriendData));
|
||||
}
|
||||
|
||||
private static IRedisConnection getConnection()
|
||||
{
|
||||
Logger.Debug("Getting a Redis connection", LogArea.Redis);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue