NewPolicyCache creates and returns a new PolicyCache instance.
(ctx context.Context)
| 71 | |
| 72 | // NewPolicyCache creates and returns a new PolicyCache instance. |
| 73 | func 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. |
no outgoing calls