mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-02 10:08:39 +00:00
I don't know what's happening anymore.
This commit is contained in:
parent
f1a0d23c99
commit
fb1a2e564d
3 changed files with 27 additions and 3 deletions
|
@ -5,7 +5,7 @@ using Redis.OM.Searching;
|
||||||
namespace LBPUnion.ProjectLighthouse.Extensions;
|
namespace LBPUnion.ProjectLighthouse.Extensions;
|
||||||
|
|
||||||
[SuppressMessage("ReSharper", "LoopCanBePartlyConvertedToQuery")]
|
[SuppressMessage("ReSharper", "LoopCanBePartlyConvertedToQuery")]
|
||||||
public static class IRedisCollectionExtensions
|
public static class RedisCollectionExtensions
|
||||||
{
|
{
|
||||||
public static void DeleteAll<T>(this IRedisCollection<T> collection, Func<T, bool> predicate)
|
public static void DeleteAll<T>(this IRedisCollection<T> collection, Func<T, bool> predicate)
|
||||||
{
|
{
|
23
ProjectLighthouse/Extensions/RedisConnectionExtensions.cs
Normal file
23
ProjectLighthouse/Extensions/RedisConnectionExtensions.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,6 +4,7 @@ using System.Diagnostics;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using LBPUnion.ProjectLighthouse.Extensions;
|
||||||
using LBPUnion.ProjectLighthouse.Helpers;
|
using LBPUnion.ProjectLighthouse.Helpers;
|
||||||
using LBPUnion.ProjectLighthouse.Logging;
|
using LBPUnion.ProjectLighthouse.Logging;
|
||||||
using LBPUnion.ProjectLighthouse.Types;
|
using LBPUnion.ProjectLighthouse.Types;
|
||||||
|
@ -38,8 +39,8 @@ public static class Redis
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await connection.CreateIndexAsync(typeof(Room));
|
await connection.RecreateIndexAsync(typeof(Room));
|
||||||
await connection.CreateIndexAsync(typeof(UserFriendStore));
|
await connection.RecreateIndexAsync(typeof(UserFriendStore));
|
||||||
|
|
||||||
initialized = true;
|
initialized = true;
|
||||||
Logger.LogSuccess("Initialized Redis.", LogArea.Redis);
|
Logger.LogSuccess("Initialized Redis.", LogArea.Redis);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue