From c1cc320030e263883936382ba37fec0f1572362c Mon Sep 17 00:00:00 2001 From: Patrick Seeburger Date: Thu, 5 Jul 2018 15:03:58 +0200 Subject: [PATCH] Improve caching of parsed birdc output. This additionally caches the results after matching regular expressions and improves performance further. Credits: Hasan Pekdemir for the original idea. --- bird/bird.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bird/bird.go b/bird/bird.go index ebf1191..8a69934 100644 --- a/bird/bird.go +++ b/bird/bird.go @@ -177,7 +177,12 @@ func ProtocolsBgp() (Parsed, bool) { for _, v := range protocols { if strings.Contains(v, " BGP ") { key := strings.Split(v, " ")[0] - bgpProto[key] = parseProtocol(v) + bgpProto[key], from_cache = fromCache(key) + if !from_cache { + parsed := parseProtocol(v) + bgpProto[key] = parsed + toCache(key, parsed) + } } }