refactor: move guildMember caching to IDiscordCache

This commit is contained in:
spiral
2021-11-21 12:06:08 -05:00
parent 99b81085ed
commit 24ac0725af
4 changed files with 32 additions and 16 deletions

View File

@@ -15,6 +15,7 @@ namespace Myriad.Cache
private readonly ConcurrentDictionary<ulong, CachedGuild> _guilds = new();
private readonly ConcurrentDictionary<ulong, Role> _roles = new();
private readonly ConcurrentDictionary<ulong, User> _users = new();
private readonly ConcurrentDictionary<ulong, GuildMemberPartial> _guildMembers = new();
public ValueTask SaveGuild(Guild guild)
{
@@ -51,6 +52,12 @@ namespace Myriad.Cache
return default;
}
public ValueTask SaveSelfMember(ulong guildId, GuildMemberPartial member)
{
_guildMembers[guildId] = member;
return default;
}
public ValueTask SaveRole(ulong guildId, Role role)
{
_roles[role.Id] = role;
@@ -149,6 +156,12 @@ namespace Myriad.Cache
return Task.FromResult(user);
}
public Task<GuildMemberPartial?> TryGetSelfMember(ulong guildId)
{
_guildMembers.TryGetValue(guildId, out var guildMember);
return Task.FromResult(guildMember);
}
public Task<Role?> TryGetRole(ulong roleId)
{
_roles.TryGetValue(roleId, out var role);