I don't know what's happening anymore.

This commit is contained in:
jvyden 2022-05-15 14:52:34 -04:00
commit fb1a2e564d
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
3 changed files with 27 additions and 3 deletions

View file

@ -5,7 +5,7 @@ using Redis.OM.Searching;
namespace LBPUnion.ProjectLighthouse.Extensions;
[SuppressMessage("ReSharper", "LoopCanBePartlyConvertedToQuery")]
public static class IRedisCollectionExtensions
public static class RedisCollectionExtensions
{
public static void DeleteAll<T>(this IRedisCollection<T> collection, Func<T, bool> predicate)
{

View file

@ -0,0 +1,23 @@
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using LBPUnion.ProjectLighthouse.Logging;
using Redis.OM;
using Redis.OM.Contracts;
namespace LBPUnion.ProjectLighthouse.Extensions;
public static class RedisConnectionExtensions
{
public static async Task RecreateIndexAsync(this IRedisConnection connection, Type type)
{
Logger.LogDebug("Recreating index for " + type.Name, LogArea.Redis);
// TODO: use `await connection.DropIndexAndAssociatedRecordsAsync(type);` here instead when that becomes a thing
bool dropped = await connection.DropIndexAsync(type);
Logger.LogDebug("Dropped index: " + dropped, LogArea.Redis);
bool created = await connection.CreateIndexAsync(type);
Logger.LogDebug("Created index: " + created, LogArea.Redis);
}
}

View file

@ -4,6 +4,7 @@ using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Logging;
using LBPUnion.ProjectLighthouse.Types;
@ -38,8 +39,8 @@ public static class Redis
return;
}
await connection.CreateIndexAsync(typeof(Room));
await connection.CreateIndexAsync(typeof(UserFriendStore));
await connection.RecreateIndexAsync(typeof(Room));
await connection.RecreateIndexAsync(typeof(UserFriendStore));
initialized = true;
Logger.LogSuccess("Initialized Redis.", LogArea.Redis);