MCPcopy Create free account
hub / github.com/conforma/cli / NewPolicyCache

Function NewPolicyCache

internal/policy/cache/cache.go:73–82  ·  view source on GitHub ↗

NewPolicyCache creates and returns a new PolicyCache instance.

(ctx context.Context)

Source from the content-addressed store, hash-verified

71
72// NewPolicyCache creates and returns a new PolicyCache instance.
73func NewPolicyCache(ctx context.Context) *PolicyCache {
74 cache, ok := ctx.Value(policyCacheKey).(*PolicyCache)
75 if ok && cache != nil {
76 return cache
77 }
78
79 return &PolicyCache{
80 Data: sync.Map{},
81 }
82}
83
84// PolicyCacheFromContext retrieves the PolicyCache from the context.
85// It returns the PolicyCache and true if found, or nil and false otherwise.

Callers 8

PreProcessPolicyFunction · 0.92
TestGetFunction · 0.85
TestSetFunction · 0.85
TestNewPolicyCacheFunction · 0.85
TestWithPolicyCacheFunction · 0.85
TestGet_ConcurrentAccessFunction · 0.85
TestGet_TypeSafetyFunction · 0.85

Calls

no outgoing calls

Tested by 7

TestGetFunction · 0.68
TestSetFunction · 0.68
TestNewPolicyCacheFunction · 0.68
TestWithPolicyCacheFunction · 0.68
TestGet_ConcurrentAccessFunction · 0.68
TestGet_TypeSafetyFunction · 0.68