Pull request: querylog: opt client search
Updates #1273.
Squashed commit of the following:
commit 6c2cc73e3360ae12aaa6e2c9834fddfdba925e2b
Merge: effe2230 fb72d543
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Mon Apr 12 14:05:04 2021 +0300
Merge branch 'master' into 1273-querylog-opt
commit effe22303fb2053dfe22b6242231b40f4d462735
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Mon Apr 12 13:21:06 2021 +0300
querylog: opt client search
This commit is contained in:
parent
fb72d543a3
commit
279350e4a3
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue