15 lines
553 B
C#
15 lines
553 B
C#
|
|
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}";
|
||
|
|
}
|