feat(api): also clear cache when leaving a guild

This commit is contained in:
sam 2024-10-24 21:10:54 +02:00
parent 5c57b75335
commit 439051999f
Signed by: sam
GPG key ID: 5F3C3C1B3166639D
10 changed files with 53 additions and 0 deletions

View file

@ -101,6 +101,14 @@ public partial class GuildsController
guildId
);
// Clear out the caches for this guild
guildCache.Remove(guildId, out _);
emojiCache.Remove(guildId);
channelCache.RemoveGuild(guildId);
roleCache.RemoveGuild(guildId);
await memberCache.RemoveAllMembersAsync(guildId);
await inviteCache.RemoveAsync(guildId);
_logger.Information("Left guild {GuildId} and removed all data for it", guildId);
return NoContent();

View file

@ -33,8 +33,12 @@ namespace Catalogger.Backend.Api;
public partial class GuildsController(
ILogger logger,
DatabaseContext db,
GuildCache guildCache,
EmojiCache emojiCache,
ChannelCache channelCache,
RoleCache roleCache,
IMemberCache memberCache,
IInviteCache inviteCache,
DiscordRequestService discordRequestService,
IDiscordRestUserAPI userApi,
WebhookExecutorService webhookExecutor