move classes around, name caches more consistently, add more caches

This commit is contained in:
sam 2024-08-19 16:12:28 +02:00
parent e86b37ce2a
commit e17dcf90a1
Signed by: sam
GPG key ID: 5F3C3C1B3166639D
30 changed files with 443 additions and 51 deletions

View file

@ -0,0 +1,21 @@
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;
}
}