MCPcopy Index your code
hub / github.com/deepflowio/deepflow / NewCacheManager

Function NewCacheManager

server/controller/recorder/cache/cache.go:48–72  ·  view source on GitHub ↗
(ctx context.Context, cfg config.RecorderConfig, md *rcommon.Metadata)

Source from the content-addressed store, hash-verified

46}
47
48func NewCacheManager(ctx context.Context, cfg config.RecorderConfig, md *rcommon.Metadata) *CacheManager {
49 mng := &CacheManager{
50 ctx: ctx,
51
52 metadata: md,
53
54 cacheSetSelfHealInterval: time.Minute * time.Duration(cfg.CacheRefreshInterval),
55 SubDomainCacheMap: make(map[string]*Cache),
56 }
57 mng.DomainCache = NewCache(ctx, md, mng.cacheSetSelfHealInterval)
58
59 var subDomains []*metadbmodel.SubDomain
60 err := mng.metadata.DB.Where(map[string]interface{}{"domain": mng.metadata.GetDomainLcuuid()}).Find(&subDomains).Error
61 if err != nil {
62 log.Errorf(dbQueryResourceFailed(ctrlrcommon.RESOURCE_TYPE_SUB_DOMAIN_EN, err), mng.metadata.LogPrefixes)
63 return mng
64 }
65 log.Infof("new sub_domain cache count: %d", len(subDomains), mng.metadata.LogPrefixes)
66 for _, subDomain := range subDomains {
67 smd := mng.metadata.Copy()
68 smd.SetSubDomain(*subDomain)
69 mng.SubDomainCacheMap[subDomain.Lcuuid] = mng.CreateSubDomainCacheIfNotExists(smd)
70 }
71 return mng
72}
73
74func (m *CacheManager) CreateSubDomainCacheIfNotExists(md *rcommon.Metadata) *Cache {
75 if _, exists := m.SubDomainCacheMap[md.GetSubDomainLcuuid()]; !exists {

Callers

nothing calls this directly

Calls 8

SetSubDomainMethod · 0.80
NewCacheFunction · 0.70
dbQueryResourceFailedFunction · 0.70
GetDomainLcuuidMethod · 0.65
ErrorfMethod · 0.45
InfofMethod · 0.45
CopyMethod · 0.45

Tested by

no test coverage detected