MCPcopy Create free account
hub / github.com/Edgio/vflow / GetCache

Function GetCache

netflow/v9/memcache.go:59–79  ·  view source on GitHub ↗

GetCache tries to load saved templates otherwise it constructs new empty shards

(cacheFile string)

Source from the content-addressed store, hash-verified

57// GetCache tries to load saved templates
58// otherwise it constructs new empty shards
59func GetCache(cacheFile string) MemCache {
60 var (
61 mem memCacheDisk
62 err error
63 )
64
65 b, err := ioutil.ReadFile(cacheFile)
66 if err == nil {
67 err = json.Unmarshal(b, &mem)
68 if err == nil && mem.ShardNo == shardNo {
69 return mem.Cache
70 }
71 }
72
73 m := make(MemCache, shardNo)
74 for i := 0; i < shardNo; i++ {
75 m[i] = &TemplatesShard{Templates: make(map[uint32]Data)}
76 }
77
78 return m
79}
80
81func (m MemCache) getShard(id uint16, addr net.IP) (*TemplatesShard, uint32) {
82 b := make([]byte, 2)

Callers 1

TestDecodeNoDataFunction · 0.70

Calls

no outgoing calls

Tested by 1

TestDecodeNoDataFunction · 0.56