item.get cache won't be hit if tags order are different (#1745)
* cache won't be hit if tags order are not the same * unit test for get items with tags
This commit is contained in:
committed by
GitHub
parent
0f144f64d9
commit
dfe360bf1d
@@ -2,6 +2,7 @@ package zabbix
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -402,6 +403,13 @@ func (ds *Zabbix) GetAllItems(ctx context.Context, hostids []string, appids []st
|
||||
}
|
||||
tagsParams = append(tagsParams, tagParam)
|
||||
}
|
||||
// tags order should be handled for higher cache hit ratio
|
||||
sort.Slice(tagsParams, func(i, j int) bool {
|
||||
if tagsParams[i]["tag"] != tagsParams[j]["tag"] {
|
||||
return tagsParams[i]["tag"] < tagsParams[j]["tag"]
|
||||
}
|
||||
return tagsParams[i]["value"] < tagsParams[j]["value"]
|
||||
})
|
||||
params["tags"] = tagsParams
|
||||
params["evaltype"] = 2
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user