feat: use redis cache for non-id message lookups
This commit is contained in:
@@ -18,6 +18,7 @@ public class PKControllerBase: ControllerBase
|
||||
protected readonly ApiConfig _config;
|
||||
protected readonly IDatabase _db;
|
||||
protected readonly ModelRepository _repo;
|
||||
protected readonly RedisService _redis;
|
||||
protected readonly DispatchService _dispatch;
|
||||
|
||||
public PKControllerBase(IServiceProvider svc)
|
||||
@@ -25,6 +26,7 @@ public class PKControllerBase: ControllerBase
|
||||
_config = svc.GetRequiredService<ApiConfig>();
|
||||
_db = svc.GetRequiredService<IDatabase>();
|
||||
_repo = svc.GetRequiredService<ModelRepository>();
|
||||
_redis = svc.GetRequiredService<RedisService>();
|
||||
_dispatch = svc.GetRequiredService<DispatchService>();
|
||||
}
|
||||
|
||||
|
@@ -20,12 +20,7 @@ namespace PluralKit.API;
|
||||
[Route("private")]
|
||||
public class PrivateController: PKControllerBase
|
||||
{
|
||||
private readonly RedisService _redis;
|
||||
|
||||
public PrivateController(IServiceProvider svc) : base(svc)
|
||||
{
|
||||
_redis = svc.GetRequiredService<RedisService>();
|
||||
}
|
||||
public PrivateController(IServiceProvider svc) : base(svc) { }
|
||||
|
||||
[HttpGet("meta")]
|
||||
public async Task<ActionResult<JObject>> Meta()
|
||||
|
@@ -92,7 +92,9 @@ public class DiscordControllerV2: PKControllerBase
|
||||
[HttpGet("messages/{messageId}")]
|
||||
public async Task<ActionResult<JObject>> MessageGet(ulong messageId)
|
||||
{
|
||||
var msg = await _repo.GetFullMessage(messageId);
|
||||
var messageByOriginal = await _redis.GetOriginalMid(messageId);
|
||||
|
||||
var msg = await _repo.GetFullMessage(messageByOriginal ?? messageId);
|
||||
if (msg == null)
|
||||
throw Errors.MessageNotFound;
|
||||
|
||||
|
Reference in New Issue
Block a user