Returns a cache if it exists and creates it otherwise
(ct CacheType, name string)
| 77 | |
| 78 | // Returns a cache if it exists and creates it otherwise |
| 79 | func (cf *cacheFactory) GetCache(ct CacheType, name string) MemoizationCache { |
| 80 | cf.lock.RLock() |
| 81 | |
| 82 | idx := string(ct) + "." + name |
| 83 | if c := cf.caches[idx]; c != nil { |
| 84 | cf.lock.RUnlock() |
| 85 | return c |
| 86 | } |
| 87 | cf.lock.RUnlock() |
| 88 | |
| 89 | cf.lock.Lock() |
| 90 | defer cf.lock.Unlock() |
| 91 | |
| 92 | if c := cf.caches[idx]; c != nil { |
| 93 | return c |
| 94 | } |
| 95 | |
| 96 | switch ct { |
| 97 | case ConfigMapCache: |
| 98 | c := NewConfigMapCache(cf.namespace, cf.kubeclient, name) |
| 99 | cf.caches[idx] = c |
| 100 | return c |
| 101 | default: |
| 102 | return nil |
| 103 | } |
| 104 | } |
nothing calls this directly
no test coverage detected