feat: add channel create responder and redis webhook cache

This commit is contained in:
sam 2024-08-16 22:28:05 +02:00
parent 99c1587e7b
commit e86b37ce2a
11 changed files with 201 additions and 10 deletions

View file

@ -0,0 +1,15 @@
using Catalogger.Backend.Database.Redis;
using Humanizer;
namespace Catalogger.Backend.Services;
public class RedisWebhookCache(RedisService redisService) : IWebhookCache
{
public async Task<Webhook?> GetWebhookAsync(ulong channelId) =>
await redisService.GetAsync<Webhook?>(WebhookKey(channelId));
public async Task SetWebhookAsync(ulong channelId, Webhook webhook) =>
await redisService.SetAsync(WebhookKey(channelId), webhook, 24.Hours());
private static string WebhookKey(ulong channelId) => $"webhook:{channelId}";
}