move classes around, name caches more consistently, add more caches
This commit is contained in:
parent
e86b37ce2a
commit
e17dcf90a1
30 changed files with 443 additions and 51 deletions
17
Catalogger.Backend/Cache/InMemoryCache/GuildCache.cs
Normal file
17
Catalogger.Backend/Cache/InMemoryCache/GuildCache.cs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
using System.Collections.Concurrent;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Remora.Discord.API.Abstractions.Objects;
|
||||
using Remora.Rest.Core;
|
||||
|
||||
namespace Catalogger.Backend.Cache.InMemoryCache;
|
||||
|
||||
public class GuildCache
|
||||
{
|
||||
private readonly ConcurrentDictionary<Snowflake, IGuild> _guilds = new();
|
||||
|
||||
public int Size => _guilds.Count;
|
||||
|
||||
public void Set(IGuild guild) => _guilds[guild.ID] = guild;
|
||||
public bool Remove(Snowflake id, [NotNullWhen(true)] out IGuild? guild) => _guilds.Remove(id, out guild);
|
||||
public bool TryGet(Snowflake id, [NotNullWhen(true)] out IGuild? guild) => _guilds.TryGetValue(id, out guild);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue