Added HREF caching

This commit is contained in:
Luca Deri 2022-09-03 11:54:46 +02:00
parent 45bcebd021
commit 7664a2eded
2 changed files with 12 additions and 1 deletions

View file

@ -289,7 +289,7 @@ else
local has_snmp_location = snmp_location and snmp_location.host_has_snmp_location(host["mac"])
local has_icmp = ((table.len(host["ICMPv4"]) + table.len(host["ICMPv6"])) ~= 0)
local has_assets = ntop.isEnterpriseL() and (host.asset_key ~= nil) and (ntop.getHashKeysCache(host.asset_key) ~= nil)
local has_assets = ntop.isEnterpriseXL() and (host.asset_key ~= nil) and (ntop.getHashKeysCache(host.asset_key) ~= nil)
local periodicity_map_available = false
local service_map_available = false
local num_periodicity = 0

View file

@ -1015,7 +1015,17 @@ function buildHostHREF(ip_address, vlan_id, page)
end
end
-- ###########################################
local _cache_map_href = {}
function buildMapHREF(service_peer, map, page)
-- cache information in order to speed-up things
if(_cache_map_href[service_peer.ip] ~= nil) then
return(_cache_map_href[service_peer.ip])
end
-- Getting minimal stats to know if the host is still present in memory
local name
local vlan = service_peer.vlan
@ -1073,6 +1083,7 @@ function buildMapHREF(service_peer, map, page)
res = string.format('<a href="%s">%s</a>', map_url, name)
end
_cache_map_href[service_peer.ip] = res
return res
end