From a2e56dccb0a6c525e1634ec35be5c8ff703cb70d Mon Sep 17 00:00:00 2001 From: Till <2353100+S7evinK@users.noreply.github.com> Date: Sat, 27 Jul 2024 22:28:52 +0200 Subject: Don't bother hitting the DB if we got everything from cache (#3376) Yet another finding where we hit the DB with a useless query. [skip ci] --- 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 b53695ca..d63c889d 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 -- cgit v1.2.3