[backend/core] Remove userPrivateKey cache in deliver queue

There's no performance difference between fetching just the private key from the user_keypair table and the previous caching implementation, so there's no point in keeping it in the cache.
This commit is contained in:
Laura Hausmann 2024-08-18 21:06:33 +02:00
parent 7627219322
commit dea43be619
No known key found for this signature in database
GPG key ID: D044E84C5BE01605

View file

@ -33,16 +33,14 @@ public class DeliverQueue(int parallelism)
logger.LogDebug("Delivering activity to: {uri}", jobData.InboxUrl);
var key = await cache.FetchAsync($"userPrivateKey:{jobData.UserId}", TimeSpan.FromMinutes(60), async () =>
{
var keypair =
await db.UserKeypairs.FirstOrDefaultAsync(p => p.UserId == jobData.UserId, token);
return keypair?.PrivateKey ?? throw new Exception($"Failed to get keypair for user {jobData.UserId}");
});
var key = await db.UserKeypairs
.Where(p => p.UserId == jobData.UserId)
.Select(p => p.PrivateKey)
.FirstOrDefaultAsync(token) ??
throw new Exception($"Failed to get keypair for user {jobData.UserId}");
var request =
await httpRqSvc.PostSignedAsync(jobData.InboxUrl, jobData.Payload, jobData.ContentType, jobData.UserId,
key);
var request = await httpRqSvc.PostSignedAsync(jobData.InboxUrl, jobData.Payload, jobData.ContentType,
jobData.UserId, key);
try
{