21 lines
No EOL
597 B
C#
21 lines
No EOL
597 B
C#
using System.Collections.Concurrent;
|
|
|
|
namespace Catalogger.Backend.Cache.InMemoryCache;
|
|
|
|
public class InMemoryWebhookCache : IWebhookCache
|
|
{
|
|
private readonly ConcurrentDictionary<ulong, Webhook> _cache = new();
|
|
|
|
public Task<Webhook?> GetWebhookAsync(ulong channelId)
|
|
{
|
|
return _cache.TryGetValue(channelId, out var webhook)
|
|
? Task.FromResult<Webhook?>(webhook)
|
|
: Task.FromResult<Webhook?>(null);
|
|
}
|
|
|
|
public Task SetWebhookAsync(ulong channelId, Webhook webhook)
|
|
{
|
|
_cache[channelId] = webhook;
|
|
return Task.CompletedTask;
|
|
}
|
|
} |