20 lines
No EOL
671 B
C#
20 lines
No EOL
671 B
C#
using System.Collections.Concurrent;
|
|
using Remora.Discord.API.Abstractions.Objects;
|
|
using Remora.Rest.Core;
|
|
|
|
namespace Catalogger.Backend.Cache.InMemoryCache;
|
|
|
|
public class InMemoryInviteCache : IInviteCache
|
|
{
|
|
private readonly ConcurrentDictionary<Snowflake, IEnumerable<IInvite>> _invites = new();
|
|
|
|
public Task<IEnumerable<IInvite>> TryGetAsync(Snowflake guildId) => _invites.TryGetValue(guildId, out var invites)
|
|
? Task.FromResult(invites)
|
|
: Task.FromResult<IEnumerable<IInvite>>([]);
|
|
|
|
public Task SetAsync(Snowflake guildId, IEnumerable<IInvite> invites)
|
|
{
|
|
_invites[guildId] = invites;
|
|
return Task.CompletedTask;
|
|
}
|
|
} |