diff options
author | Till <2353100+S7evinK@users.noreply.github.com> | 2024-07-27 22:28:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-27 22:28:52 +0200 |
commit | a2e56dccb0a6c525e1634ec35be5c8ff703cb70d (patch) | |
tree | 077dd7b9a07b104d68ff3036add09c7aefc1ec72 | |
parent | 38549e649ed873257ca958beff272bf3f38288f8 (diff) |
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]
-rw-r--r-- | federationapi/storage/cache/keydb.go | 4 |
1 files changed, 4 insertions, 0 deletions
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 |