Skip to content

Commit

Permalink
querylog: opt client search
Browse files Browse the repository at this point in the history
  • Loading branch information
ainar-g committed Apr 12, 2021
1 parent 8b8319f commit effe223
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions internal/querylog/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import (
// find those records as well.
func (l *queryLog) client(clientID, ip string, cache clientCache) (c *Client, err error) {
cck := clientCacheKey{clientID: clientID, ip: ip}
if c = cache[cck]; c != nil {

var ok bool
if c, ok = cache[cck]; ok {
return c, nil
}

Expand All @@ -33,9 +35,9 @@ func (l *queryLog) client(clientID, ip string, cache clientCache) (c *Client, er
return nil, err
}

if cache != nil {
cache[cck] = c
}
// Cache all results, including negative ones, to prevent excessive and
// expensive client searching.
cache[cck] = c

return c, nil
}
Expand Down

0 comments on commit effe223

Please sign in to comment.