init
This commit is contained in:
commit
ded4f4db26
43 changed files with 2052 additions and 0 deletions
21
Catalogger.Backend/Services/InMemoryWebhookCache.cs
Normal file
21
Catalogger.Backend/Services/InMemoryWebhookCache.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
using System.Collections.Concurrent;
|
||||
|
||||
namespace Catalogger.Backend.Services;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue