From dea43be6198b8dbd38fe4bd2dd4a430e640fbb08 Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Sun, 18 Aug 2024 21:06:33 +0200 Subject: [PATCH] [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. --- Iceshrimp.Backend/Core/Queues/DeliverQueue.cs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Iceshrimp.Backend/Core/Queues/DeliverQueue.cs b/Iceshrimp.Backend/Core/Queues/DeliverQueue.cs index 63dae9f5..19e7cc36 100644 --- a/Iceshrimp.Backend/Core/Queues/DeliverQueue.cs +++ b/Iceshrimp.Backend/Core/Queues/DeliverQueue.cs @@ -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 {