mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-13 01:00:12 +00:00
refactor: move guildMember caching to IDiscordCache
This commit is contained in:
parent
99b81085ed
commit
24ac0725af
4 changed files with 32 additions and 16 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue