From 7b7a176c681ae649e8b2e44a28481cb9568eeec9 Mon Sep 17 00:00:00 2001 From: Till Faelligen <2353100+S7evinK@users.noreply.github.com> Date: Thu, 16 May 2024 19:53:22 +0200 Subject: [PATCH] Don't bother hitting the DB if we got everything from cache. --- federationapi/storage/cache/keydb.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/federationapi/storage/cache/keydb.go b/federationapi/storage/cache/keydb.go index b53695ca4..d63c889d5 100644 --- a/federationapi/storage/cache/keydb.go +++ b/federationapi/storage/cache/keydb.go @@ -46,6 +46,10 @@ func (d *KeyDatabase) FetchKeys( delete(requests, req) } } + // Don't bother hitting the DB if we got everything from cache. + if len(requests) == 0 { + return results, nil + } fromDB, err := d.inner.FetchKeys(ctx, requests) if err != nil { return results, err