set cached methods

This commit is contained in:
Alexander Zobnin
2020-06-02 17:26:24 +03:00
parent ff0b8b9dff
commit d8d83484af

View File

@@ -14,12 +14,14 @@ import (
"golang.org/x/net/context" "golang.org/x/net/context"
) )
var NotCachedMethods = map[string]bool{ var CachedMethods = map[string]bool{
"history.get": true, "hostgroup.get": true,
"trend.get": true, "host.get": true,
"problem.get": true, "application.get": true,
"trigger.get": true, "item.get": true,
"apiinfo.version": true, "service.get": true,
"usermacro.get": true,
"proxy.get": true,
} }
// ZabbixQuery handles query requests to Zabbix // ZabbixQuery handles query requests to Zabbix
@@ -35,7 +37,7 @@ func (ds *ZabbixDatasourceInstance) ZabbixQuery(ctx context.Context, apiReq *Zab
return nil, err return nil, err
} }
if _, ok := NotCachedMethods[apiReq.Method]; !ok { if _, ok := CachedMethods[apiReq.Method]; ok {
ds.logger.Debug("Write result to cache", "method", apiReq.Method) ds.logger.Debug("Write result to cache", "method", apiReq.Method)
ds.queryCache.Set(requestHash, resultJson) ds.queryCache.Set(requestHash, resultJson)
} }