LANCommander/LANCommander.Server.Services/Extensions/CacheExtensions.cs
2025-02-23 08:50:16 -06:00

18 lines
No EOL
561 B
C#

using ZiggyCreatures.Caching.Fusion;
namespace LANCommander.Server.Services.Extensions;
public static class CacheExtensions
{
public static async Task ExpireGameCacheAsync(this IFusionCache cache)
{
await cache.RemoveByTagAsync(["Games", "Depot"]);
}
public static async Task ExpireGameCacheAsync(this IFusionCache cache, Guid? gameId)
{
if (gameId.HasValue)
await cache.RemoveByTagAsync([ $"Games/{gameId}", "Games", "Depot"]);
else
await cache.RemoveByTagAsync(["Games", "Depot"]);
}
}