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

Function GetCache

ipfix/memcache.go:60–80  ·  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

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

Callers 12

runMethod · 0.92
TestMemCacheRetrieveFunction · 0.70
TestMemCacheInsertFunction · 0.70
TestMemCacheAllSetIdsFunction · 0.70
TestDecodeNoDataFunction · 0.70
TestDecodeTemplateFunction · 0.70
TestDecodeOptsTemplateFunction · 0.70
BenchmarkDecodeTemplateFunction · 0.70
TestMultiMessageFunction · 0.70
TestDecodeDataTplFunction · 0.70

Calls

no outgoing calls

Tested by 11

TestMemCacheRetrieveFunction · 0.56
TestMemCacheInsertFunction · 0.56
TestMemCacheAllSetIdsFunction · 0.56
TestDecodeNoDataFunction · 0.56
TestDecodeTemplateFunction · 0.56
TestDecodeOptsTemplateFunction · 0.56
BenchmarkDecodeTemplateFunction · 0.56
TestMultiMessageFunction · 0.56
TestDecodeDataTplFunction · 0.56