2024-08-13 13:08:50 +02:00
|
|
|
using System.Collections.Concurrent;
|
|
|
|
|
|
2024-08-19 16:12:28 +02:00
|
|
|
namespace Catalogger.Backend.Cache.InMemoryCache;
|
2024-08-13 13:08:50 +02:00
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
2024-10-09 17:35:11 +02:00
|
|
|
}
|