NewLoadingCache creates a new instance of a loading cache with capacity. Capacity must be >= 0, or it will panic. Capacity == 0 means the cache growth is unbounded.
(load loadFunc, capacity int)
| 30 | // NewLoadingCache creates a new instance of a loading cache with capacity. Capacity must be >= 0, or |
| 31 | // it will panic. Capacity == 0 means the cache growth is unbounded. |
| 32 | func NewLoadingCache(load loadFunc, capacity int) *loadingCache { |
| 33 | if capacity < 0 { |
| 34 | panic("capacity must be >= 0") |
| 35 | } |
| 36 | return &loadingCache{cap: capacity, load: load, m: make(map[interface{}]interface{})} |
| 37 | } |
| 38 | |
| 39 | func (c *loadingCache) get(key interface{}) (interface{}, error) { |
| 40 | c.RLock() |
no outgoing calls
searching dependent graphs…