Skip to content

Commit

Permalink
Pull request: querylog: opt client search
Browse files Browse the repository at this point in the history
Updates #1273.

Squashed commit of the following:

commit 6c2cc73
Merge: effe223 fb72d54
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Mon Apr 12 14:05:04 2021 +0300

    Merge branch 'master' into 1273-querylog-opt

commit effe223
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Mon Apr 12 13:21:06 2021 +0300

    querylog: opt client search
  • Loading branch information
ainar-g committed Apr 12, 2021
1 parent fb72d54 commit 279350e
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 279350e

Please sign in to comment.