2024-08-16 22:28:05 +02:00
|
|
|
using Catalogger.Backend.Database.Redis;
|
|
|
|
|
using Humanizer;
|
|
|
|
|
|
2024-08-19 16:12:28 +02:00
|
|
|
namespace Catalogger.Backend.Cache.RedisCache;
|
2024-08-16 22:28:05 +02:00
|
|
|
|
|
|
|
|
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}";
|
2024-10-09 17:35:11 +02:00
|
|
|
}
|